Questions tagged as 'linq'

2
answers

How to make LINQ filter for every X months?

Hello, I would like to know the best way to filter a list of objects using LINQ in C #, I have a list of objects called Measurement , each measurement has a Date property, which is the date that was registered. What I want to respond to is:...
asked by 18.01.2016 / 20:00
3
answers

Where dynamic Linq to SQL

I need to mount a where clause with the field and the dynamic value, for example, in pure SQL would be: WHERE :CAMPO = :VALOR However, scouring the queries I could not find anything specific, I'm already doing queries in the database...
asked by 26.04.2016 / 21:04
1
answer

Linq Compare two lists of different types

I have two different lists A List<ProdutoTag> and B = List<Tag> : public class ProdutoTag { public Int64 ProdutoId { get; set; } public Int32 TagId { get; set; } public Double Peso { get; set; } public...
asked by 23.02.2016 / 18:38
2
answers

How to make a LINQ / lambda and consume it in the view?

I have an object called Radio : public class Radio { public int RadioId { get; set; } public string StreamUrl { get; set; } public bool Ativo { get; set; } public bool Mp3 { get; set; } } I'm doing a select in control...
asked by 09.08.2015 / 14:45
2
answers

What is the 'let' statement in a LINQ query?

I have the following LINQ query: var source = from em in query select new { Id = em.UniqueID, Data = em.Data == DateTime.MinValue ? "" : em.Data.Value.ToString("dd/MM/yy HH:mm")...
asked by 14.12.2015 / 17:15
2
answers

How to map and get only one property or field of a query?

I'm using Dapper to map object properties . See a practical example: var servico = conexao.Query<Servico>(statement.ToSql(), new { IdServico = id }).First(); That is, the Servico object will have all its properties mapped a...
asked by 29.01.2017 / 16:07
3
answers

C # update XML based on another XML

Today I have the following XML structure: <ROOT> <TES IDTES="4780" IDPES="17522" /> <TES IDTES="6934" IDPES="12343" /> <TES IDTES="4781" IDPES="17523" /> <TES IDTES="6935" IDPES="12344" /> </ROO...
asked by 16.04.2014 / 22:23
2
answers

Error in .First (), because there is no result selected

In my controller login I use the following code to make the user selection if it exists, however whenever the user types the incorrect name or password, an error because it does not find the result for .First . I need to make a treatmen...
asked by 04.12.2015 / 20:25
1
answer

Error There are no comments for in the schema

I'm following a tutorial to access database via LINQ. In the video, I saw a function that returns me a list with the data of the database: public static List<LicitacaoOffline> Buscar() { DatabaseEstoqueOfflineDataContext oDB = new...
asked by 28.12.2016 / 18:56
3
answers

Group by interval of days using Linq

How can I use interval grouping with Linq? var dados = new[] { new { Id = 0, dias=100, preco= 25, Nome="etc"}, new { Id = 1, dias=40, preco= 50, Nome="etc1"}, new { Id = 2, dias=50, preco= 55, Nome="etc2"}, new { Id = 3, d...
asked by 08.06.2017 / 21:57