Questions tagged as 'linq'

2
answers

Foreach or lambda in lists

What do I get the best performance to get the value of a data in a list? Do foreach or lambda (when possible, of course)? I can have this: foreach(var i in lista) { var teste = i.NmCampo; } Or this: var teste = lista.Select(campo...
asked by 11.03.2015 / 13:09
2
answers

How does GroupBy work in LINQ?

I'm having trouble understanding the GroupBy operator in LINQ.     
asked by 26.08.2015 / 21:23
1
answer

Scroll bar on a table with bootstrap

I have a table, where I load information from the database into it. It has two columns (CNPJ and Social Reason). The table I mounted with bootstrap. I would like it to have a maximum height and create scrollbar (I find that difficult), as I do n...
asked by 27.06.2014 / 15:01
2
answers

How to get all records of a mixed table generated by class inheritance when using EntityFramework 6?

I have a class structure in the following form: public class Pessoa { public int Id {get; set;} public string Nome {get; set;} } public class Membro : Pessoa { public int CargoId {get; set;} public Cargo Cargo {get; set;} } p...
asked by 21.04.2014 / 17:12
1
answer

How do I extract the values of an Expression?

Hello. Is it possible to extract from an Expression what filters, computers, etc. were used in a query? Example: public class Program { class Produto { public int Id; public string Nome; public Produto(int i...
asked by 06.10.2015 / 22:15
3
answers

LINQ with condition in where using variable

I have the following table: USUARIO Nome | Idade João | 21 Maria | 18 I want to make only one query that returns all users, or only returns users of a specific age based on a C # variable. Also by name. int idade = 18;...
asked by 26.08.2015 / 22:01
2
answers

Performative difference of Any () and Count ()

When I need to check whether a collection has elements which of the two methods will be faster, .Count() =! 0 or .Any() ? I've heard that .Count() may be faster in some cases. But by checking the source code , the metho...
asked by 11.08.2015 / 18:33
2
answers

Find item in a list using LINQ

I have a list and I want to search it (as if it were a database). Is it possible? Ex: list all list names starting with 'JOAO%'     
asked by 19.01.2017 / 12:58
3
answers

LINQ corresponding to SQL with LIKE clause 'XXX%'

I'm using the following LINQ to return a query: .Where(c => c.Nome.Contains(nome)).OrderBy(c => c.Nome) But if the name is Maria , it brings: José Maria Maria José How to bring organized as if executing SQL query? So: WHE...
asked by 12.10.2015 / 21:38
4
answers

Make an update with lambda

I have a query in lambda that returns me a list of data. I would like to know how do I update this DB table using lambda? Let's say, I have a Table called T_PDV and in it a flag field, where milestone LIDO = 1 and if it is not LIDO = 0. This f...
asked by 02.06.2014 / 18:51