Questions tagged as 'linq'

2
answers

How does the Where logic in the Entity Framework work?

I'm studying C # and just did my first query in the Data Bank: using System; using System.Data.Entity.Core; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace Test.Models {...
asked by 28.04.2016 / 19:42
2
answers

Inquiry Lambda

I have the following query in T-SQL : SELECT TOP (60) COUNT(*) AS QTD, SUM(Duration) AS Total, AVG(Duration) AS Media, MIN(Duration) AS Menor, LEFT (TextData, 80) AS TextData FROM Traces WITH (nolock) WHERE (StartTime &g...
asked by 20.03.2014 / 14:17
2
answers

Nomenclature or language in lambda

We have this expression: var teste = meucotexto.minhatable.Where(x => x.meu_campo.....) How do I read this part x => x.meu_campo I read x is for x.my field or x for x.my field or something else?     
asked by 24.06.2014 / 14:10
1
answer

Order By with List

Is it possible to make a OrderBy in a List<> setting the value for comparison? Example: mRel.OrderBy(s => s.Status == EnumModel.StatusGeral.Novo).ToList() My Code: List<MotivosModel.MotivosRel> mRel = Carre...
asked by 04.05.2017 / 17:43
3
answers

Count or Count ()

Having a list, what is the best way to know the number of items on this list and what is the difference? if (minhaLista.Count > 0) ; or if (minhaLista.Count() > 0) ;     
asked by 07.10.2016 / 18:43
1
answer

How does Linq's Aggregate () extension method work?

I recently saw some examples that used the Aggregate() of namespace System.Linq method, but I could not find any good explanation of how to use it. What does this method do and how should it be used?     
asked by 06.10.2015 / 15:22
2
answers

Foreach C # vs ForEach () EF6

Follow the code below: % of EF6%: var result = ctx.Table.Where(x => x.User == "João").ToList(); result.ForEach(x => x.Read = true); ctx.SaveChanges(); ForEach() of C #: var result = ctx.Table.Where(x => x.User == "João...
asked by 07.06.2017 / 20:45
2
answers

How to sort by two properties in Linq

I have the following syntax and it is not working return View(trabalhos.Where(a => a.Usuario == User.Identity.Name && a.Data.Month == DateTime.Today.Month &&...
asked by 27.01.2017 / 19:41
1
answer

Left join with lambda GroupJoin and with condition

How can I make a left join with some conditions using LINQ lambda expressions? In SQL Server I have this query: select usr.Id, usr.FirstName, usr.LastName, ex.Id from User usr left join Exam ex on ex.Id = usr.IdExam and (ex.Id is...
asked by 11.02.2015 / 20:02
3
answers

How to make a query through LINQ ignoring accents?

I would like to know if you can do a query with LINQ that compares two strings and ignores their accents. That's not my Collation in the database is set to AI and that I do not need to replace in the strings to exit by re...
asked by 12.05.2017 / 04:10