Questions tagged as 'linq'

1
answer

Can LINQ be considered a business rule?

Sometimes I pull active objects with LINQ expression. Using filtering with LINQ can be considered business rule and in a scenario like Domain-Driven Design (DDD))? What is the best place to use (in Domain services or in Infra repos...
asked by 28.01.2017 / 13:13
1
answer

Use LINQ aggregator dynamically

I'm trying to create a function to use Linq aggregator functions (sum, average, count) and I'm not succeeding. I have the following code: private double AgreggateDynamic<T>(IEnumerable<T> list, string propertyName, string func)...
asked by 22.01.2016 / 20:24
1
answer

Conversion error in a linq query

I made this query and Where is giving this error: Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<AnonymousType#1>' to 'System.Collections.Generic.List<AnonymousType#1>' Missed this part string _cnpj = c...
asked by 26.06.2014 / 22:11
1
answer

LINQ Lambda | Query Syntax VS Method Syntax Performance [duplicate]

Doubt regarding construction and performance of querys using Query Syntax and Method Syntax / LINQ Query Syntax: var VendorQuery = from v in vendors where v.CompanyName.Contains("Toy")...
asked by 27.12.2018 / 10:58
1
answer

Make a query in Linq and see in index

I wanted a linq query that shows the attributes of the availability table and the name of the respective catechist that is in the person table. In the index will appear: Nome | AnoPastoral | DiaDisponivel | HoraDisponivel | Observacoes I'm...
asked by 14.12.2015 / 13:24
4
answers

"Filter" equal records in a list by adding their quantitative

namespace ConsoleApplication10 { class Program { static void Main(string[] args) { List<Teste> lstTeste = new List<Teste> { new Teste {Codigo = 1, Quantidade = 10},...
asked by 22.09.2015 / 22:22
2
answers

Sorting data with value priority using LINQ

I have a status table with the following values: ID 1 = Ativo ID 2 = Novo ID 3 = Excluido How would you return a list of objects (which have the status object) prioritizing, coming first, those that have Status 2 (New) using LINQ? I wou...
asked by 16.09.2015 / 18:39
2
answers

How to select fields in a query in lambda expression?

Through% of LINQ% I can select which fields will be displayed in the query, for example: var subCategorias = from s in db.SubCategoria join c in db.CategoriaProduto on s.id_categoria equals c.id_cat...
asked by 09.06.2016 / 02:47
1
answer

Doubt between Any and All in a lambda expression in a list

In a list, I have 12 records (hypothetical) and there is a field called ValorCampoFlag , where this field receives 1 or null , for example. If I do a validation on it and the result if there is at least one with a value of 1, should...
asked by 12.02.2015 / 13:30
2
answers

ToList vs. Typed ToList

I was reviewing some methods of an ASP.NET MVC project and found some cases where only .ToList() is used and others where .ToList<type>() is used (where type is a type of object used in context). Imagine that only with...
asked by 14.03.2017 / 13:07