Questions tagged as 'linq'

3
answers

What's the difference between IEnumerable, IQueryable and List?

What is the difference between IEnumerable , IQueryable and List in .NET? When is it better to use one or the other? Why does ReSharper suggest changing the return of this function, for example, from List<T> : private Li...
asked by 27.05.2014 / 18:50
2
answers

What is the difference between "lambda" and LINQ? How to differentiate them in a sentence?

I often see terms like LINQ query and lambda expressions . Then the question came up, What I'm doing is a LINQ query, a lambda expression, or both? Ex1: var query = Produtos.Where(p => p.Descr.StartsWith("A")).Take(10); Ex2: var...
asked by 09.08.2015 / 04:07
3
answers

What is the System.Linq in C #?

I asked this question here in SOPT What is the equivalent of PHP's array_map in C #? And I was curious to know what this System.Linq is about. Because when I tried to use the above response code without using it, I got an error...
asked by 27.04.2016 / 17:48
3
answers

Difference between Any, Contains and Exists

What is the difference between Any , Contains and Exists ? What is the appropriate context for each of them? (Examples of use) What are the advantages and disadvantages?     
asked by 10.12.2015 / 13:29
2
answers

Is there an opposite for 'contains'?

I have a list: List<int> lista1 = new List<int>(); lista1.Add(1); lista1.Add(2); lista1.Add(3); List<int> lista2 = new List<int>(); lista2.Add(1); lista2.Add(2); To get from lista1 elements that also exist in...
asked by 12.08.2015 / 21:54
2
answers

Why is AddRange much faster than Add?

I'm working on a data integration between two bases, and I'm using Entity Framework for this. I then generated the following code, which iterates each record in the Situations table of base dbExterno and feeds my base db :...
asked by 11.12.2013 / 18:36
3
answers

What is the advantage of using the Set method?

What is the advantage or difference in using the Set<> method, and can I do the same without it as in alternative 2? Alternative 1 var aluno = contexto.Alunos.First(x => x.Id == entidade.Id); contexto.Set<**Aluno**>()....
asked by 22.09.2015 / 00:39
2
answers

How to Lambda in Extension Methods with multiple Lists?

There are the following Objects: public class Objeto1 { public List<Objeto2> PropObj1 {get; set;} } public class Objeto2 { public List<Objeto3> PropObj2 {get; set;} } public class Objeto3 { public int PropObj3 {get; set;...
asked by 10.08.2015 / 22:55
2
answers

Lambda GroupBy by year and month

I have a list of events, and I would like to group them by year and month, for example [Year 2017] Month January  {Event 1, Event 2, Event 2} Month February  {Event 3} [Year 2018] Month January  {Event 4, Event 5} I'm us...
asked by 11.01.2017 / 20:43
5
answers

Is it recommended to use Linq instead of SQL?

To avoid string abuse and avoid code injection problems it may be a good practice to use Linq . I can also imagine, for example, that it be slower. Who has used Linq to communicate with database, would you recommend it?     
asked by 14.12.2013 / 23:31