Questions tagged as 'linq-to-entities'

1
answer

In the Entity Framework, do the SingleOrDefault () and FirstOrDefault () methods have different behaviors?

What are the differences between SingleOrDefault() and FirstOrDefault() , and when to use it?     
asked by 09.06.2014 / 00:18
2
answers

Returning a list using select new with LINQ

I can do this: var filial = (from f in base.EntityContext.vw_filial select f).ToList<vw_filial>(); But, I want to do something like this: var filial = (from f in base.EntityContext.vw_filial select new {...
asked by 18.12.2014 / 12:47
2
answers

How is the generated query created in Linq when we do UPDATE?

How is the generated query created in Linq when we do UPDATE? using ColWebDBContext.DBase.Banco; using System; using System.Web.UI; using System.Linq; namespace DBContext { public partial class _Default : Page { protected void...
asked by 28.10.2016 / 20:24
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
4
answers

Problems initializing a type inside a query with LINQ

I'm going through the following problem, I am putting an API into a forum application and this API needs an endpoint to return a collection of Forum that have the% property of% null. Then I put the following endpoint : [AllowAnonymou...
asked by 06.01.2016 / 11:43
1
answer

How to know which SQL is generated by the ORM Entity Framework?

With the use of the ORM , and the practice employed we forget that they generate SQLs and return Objetos (vice versa). How can I find out at runtime the SQL generated by the Entity Framework directly in Visual Stud...
asked by 14.06.2014 / 17:48
3
answers

How to create extension methods in the Entity Framework using Linq?

Is it possible to create custom extension methods for Linq to entities? In the project I work with, for example, we have several columns of type DateTimeOffset? . In certain views I need to filter the results by date, so I do the follow...
asked by 02.09.2016 / 16:35
1
answer

Get the largest value inside linq select

Is there any way I can get the highest value of a select do linq field within decimal? , as per the code below? MaxValor = Math.Max(CF.Janeiro, CF.Fevereiro, CF.Marco, CF.Abril, CF.Maio, CF.Junho, CF.Julho, CF.Agosto, CF.Setembro,...
asked by 16.12.2015 / 19:49
1
answer

Query Return - Generic Repository Entity Framework

I have a generic repository and I realized that it is taking a long time to return a query with the selection of some columns of my database, the Query () method is as follows: public IList<T> Query(System.Linq.Expressions.Expression<...
asked by 26.04.2018 / 13:24
1
answer

Do a join make the search faster?

I have two tables, one for patients and one for queries. In summary, the tables have the following structure: Patients int id; string nome; string cartaoSus; Queries int id; int idPaciente; dateTime data; When I want a patient r...
asked by 05.07.2017 / 15:11