Most voted "linq-to-entities" questions
LINQ to Entities provides LINQ (Integrated Language Query) support that allows developers to write queries in the Entity Framework conceptual model using Visual Basic or Visual C#.
Learn more…52 questions
Sort by count of
-
9
votes1
answer936
viewsIn the Entity Framework, do the Singleordefault() and Firstordefault() methods exhibit different behaviors?
What are the differences between SingleOrDefault() and FirstOrDefault(), and when to use?
-
7
votes2
answers1398
viewsReturning a list using select new with LINQ
I can do it: 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…
-
6
votes1
answer1827
viewsHow to know which SQL is generated by the ORM Entity Framework?
With the use of 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 Entity Framework right in the…
sql entity-framework entity-framework-6 lambda-expressions linq-to-entitiesasked 10 years, 6 months ago user6026 -
6
votes2
answers687
viewsHow is the query generated in Linq mounted when we do UPDATE?
How the query generated in Linq is mounted when we do UPDATE? using ColWebDBContext.DBase.Banco; using System; using System.Web.UI; using System.Linq; namespace DBContext { public partial class…
-
5
votes2
answers213
viewsValue priority data ordering 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 (that have the status object) prioritizing, coming first, those…
-
4
votes4
answers144
viewsProblems initializing a type within a LINQ query
I am going through the following problem, I am assembling an API for a forum application and this API needs a endpoint returning a collection of Forum who own the property ParentId nulla. Then I…
-
4
votes1
answer219
viewsQuery Return - Generic Entity Framework Repository
I have a generic repository and I realized that it is taking too long to return a query with the selection of some columns of my database, the Query() method is as follows: public IList<T>…
-
4
votes3
answers470
viewsLeft Join with LINQ
I have two tables that come from different repositories. One comes from an API and I have one that comes from BD. I already have the two tables mapped to classes. I want to select all records from…
-
4
votes1
answer578
viewsHow to generate a subquery in Line/EF
Hello, everybody. I have a situation, where I concatenate some subquerys Sqls that are concatenated into other Sqls queries, to return some values. I have several functions like these, because I use…
sql-server entity-framework linq linq-to-entities linq-to-sqlasked 5 years, 10 months ago Fabiano Richetti 41 -
3
votes1
answer1373
viewsProblem returning Entity models: "The Entity or Complex type ... cannot be constructed in a LINQ to Entities query"
I’m trying to return a list of objects generated by the Entity Framework Database First but I get this error: The Entity or Complex type 'leaosites04Model.TB_LEMBRETES' cannot be constructed in a…
c# entity-framework linq entity-framework-6 linq-to-entitiesasked 10 years, 5 months ago Reynaldo 141 -
3
votes1
answer108
viewsSearch for missing record range
Imagine the following situation: a table looks like this: Id (int) - Codigo (int) - Descricao (varchar) 1 - 01 - Descrição 1 2 - 03 - Descrição 2 3 - 04 - Descrição 3 4 - 05 - Descrição 4 Note that…
-
3
votes1
answer931
viewsTake the highest value within the Line select
Is there any way that inside the select do linq I can take the highest value of a field of the type decimal?, according to the code below? MaxValor = Math.Max(CF.Janeiro, CF.Fevereiro, CF.Marco,…
-
3
votes3
answers151
viewsHow to create extension methods in the Entity Framework using Linq?
You can create custom extension methods for Linq to entities? In the project I work, for example, we have several columns of type DateTimeOffset?. In certain views I need to filter the results by…
-
3
votes1
answer110
viewsDoes "Join" make the search faster?
I have two tables, one of patients and the other of consultations. In short, the tables have the following structure: Patients int id; string nome; string cartaoSus; Consultation int id; int…
c# entity-framework linq lambda-expressions linq-to-entitiesasked 7 years, 5 months ago Italo Rodrigo 4,344 -
2
votes1
answer167
viewsHow to search for the record when the table has a composite primary key?
I have in my database the table t_command_control. This table has a composite primary key formed by the fields CD_STATION and CD_COMMAND. If the primary key was simple (only as a field CD_STATION) i…
-
2
votes1
answer526
viewsIqueryable select data from multiple tables
I have a queryable (Linq to entities) in the Entityframework and I’m not able to pull data from two or more tables. For example: var model = _service.List().Where(m =>…
-
2
votes1
answer1058
viewsHow do I add more than two conditions to an Expression dynamically?
I need to pass a list of Expressions as a parameter and create the Ands in the most dynamic way possible. Just like that, whenever I add a new Expression on the list, I’m going to have to change the…
-
2
votes1
answer87
viewsConvert SQL script to Linq
I need to convert the SQL script below to Linq. SELECT [ID_Pessoa], [ID_ArquivoPagamento], SUM([Peculio_Valor]) AS 'Peculio_Valor' FROM [VW_PESSOA] WHERE [ID_Pessoa] = @ID_Pessoa AND…
-
2
votes1
answer44
viewsSave Ienumerable<T> inside a parent entity with LINQ
I have the following classes: public class Foto { [Key] public int Id { get; set; } [StringLength(500)] [Required(ErrorMessage = "Obrigatório")] public string Nome { get; set; } public int Item_Id {…
-
2
votes1
answer49
viewserror with EF and Mysql query
I have the following consultation: var produto = (from a in context.ItensReceita join b in context.Receita on a.t0080_id_receita equals b.t0080_id_receita join c in context.Medicamento on…
mysql entity-framework datetime linq-to-entitiesasked 7 years, 10 months ago alessandre martins 998 -
2
votes2
answers123
viewsHelp with LINQ, query no . Net
Good morning, guys, I could use a little help with LINQ. I am trying to perform the following query through the: SELECT NFE_SAIDA.NFESAI_SEQUENCIA FROM CAD_NFE_SAIDA NFE_SAIDA LEFT JOIN…
-
2
votes1
answer379
viewsConvert SQL to LINQ
I have the following table CREATE TABLE `ultimaposicaorastreadores` ( `Id` CHAR(36) COLLATE utf8_bin NOT NULL DEFAULT '', `Serial` BIGINT(20) NOT NULL, `DataGps` DATETIME NOT NULL, PRIMARY KEY USING…
c# sql entity-framework entity-framework-6 linq-to-entitiesasked 6 years, 11 months ago b3r3ch1t 805 -
2
votes1
answer181
viewsWhat is the difference between using "equals" vs == in LINQ to Entities?
As quoted above, when I say equals from LINQ to Entities I am referring specifically to the reserved word of C# and not to the Equals() of System.Object. Source: equals (Reference of C#) The…
-
2
votes2
answers124
viewsJunction of 2 Linq Queries
I am using the mysql database. I have 2 tables one of questions and options related to the question. For every access I make to the system I need to take the questions randomly and obviously the…
-
1
votes1
answer154
viewsBank table does not update
I have in my database some tables they already contain data saved, but I am not able to update this data. I have the method below that performs the insertion of a new item in the table if the table…
-
1
votes2
answers104
viewsWhen concatenating into LINQ returns error
I did this LINQ. In the concatenation between DDD and phone number, which I call phone 1 is giving dick. var agendamento = ( from pdv in db.T_PDV from tarefa in db.T_TarefaParceiro.Where(trf =>…
-
1
votes1
answer113
viewsLinq Return all records when ID is NULL
Consultation: retorno = tarefaRep.GetAll(c => c.status == 0 && c.id_empresa == idEmpresa && c.id_cliente.ToString().Equals(idCliente) &&…
-
1
votes1
answer169
viewsVery difficult to mount an update with Linnus
I’ve done some updates with Ingles no problem. but the way my code is, I’m having trouble. What’s the rule: 1) I have a screen where I do some reporting requests. Soon I may have n requests in…
-
1
votes2
answers454
viewsHow to convert Float to String using LINQ for Entity?
How to convert Float to String using LINQ to Entity? I need to convert a field from my database that has the float type to the string type in my C# using the LINQ. Try using Convert.Tostring,…
-
1
votes1
answer167
viewsDoubt with Join between two classes
I have the Classes: class Procedimento { public string CodProcedimento { get; set; } public string NomeProcedimento { get; set; } public string TpSexo { get; set; } public int IdadeMinima { get;…
-
1
votes2
answers51
viewsFiltering through empty children
I have two entities (TipoDeRequerimento and TipoRequerimentoSituaçãoAcademica) in my query. Today I can make a filter to bring the Types of requirements that have a certain academic situation…
c# asp.net-mvc asp.net-web-api lambda-expressions linq-to-entitiesasked 7 years, 2 months ago Thiago Ubiratan 353 -
1
votes0
answers70
viewsDoubt with LINQ to Entities
What would this query look like in LINQ to Entities: SELECT COUNT(cont) qtde_resp , pergunta , resposta FROM pesq_respostas WHERE id_pesquisa = 9 AND Tipo IN ('Intervalo', 'SimNao') GROUP BY…
c# sql entity-framework lambda-expressions linq-to-entitiesasked 6 years ago alessandre martins 998 -
1
votes1
answer28
viewsGenerate a Partial Model from a complete Model
I have a Model called: Cliente_man that represents the customer register. But this Model, has a lot of information, and to the screen that I am developing not ah need of all, so I would like to move…
-
1
votes1
answer46
viewsWhat do you call the cast() function of the database in the ORDER method of a database in a LINQ expression in C# C#?
I have a field that stores DATETIME in my database. However I need to ignore the time of this field when I am ordering for it. The following code makes my search: public virtual async…
asp.net entity-framework linq linq-to-entities asp-net-coreasked 5 years, 7 months ago Daniel Silva 11 -
1
votes1
answer49
viewsDoubt syntax: How to find the minimum and maximum value of a field in Line with Where
I need to create a function in linq return me the minimum and maximum values of a field in a list. I was able to perform an SQL query in this way, but I need this in the syntax in linq. SELECT…
-
0
votes2
answers391
viewsIs there a difference between First and Single?
There are some differences between First and Single? the return of the two consultations are equal? And in the performance between the two is the same? Which of the two expressions is best used?…
-
0
votes1
answer140
viewsQuery with Linq to Entities in Many-to-Many relationship
I have the following tables in a database: The table Coursesprofessors joins the relationship Many-to-Many between the tables Courses and Teachers. I have been trying for a long time to do a query…
-
0
votes1
answer221
viewsInstruction Left Join in LINQ to entites
I tried to do a left Join on LINQ as follows: (from opr in db.Operacao join vol in db.Volume on new { VOL_CODBAR = opr.OPR_CODBAR } equals new { VOL_CODBAR = vol.VOL_CODBAR } into vol_join from vol…
-
0
votes2
answers1454
viewsapply filter in return from a list
I’m making an appointment where I have one array of situations ex: 1, 2, 3 in the query I have to filter through these situations, follow my code. var array = GetSituacoes(); var lista = bll.Query(p…
c# entity-framework linq lambda-expressions linq-to-entitiesasked 7 years, 7 months ago Thiago Ubiratan 353 -
0
votes0
answers40
viewsLINQ not recognizing method that returns a Boolean
I’m having this mistake when I try to perform a query with the Entity within a Iqueryable. "LINQ to Entities does not recognize the method 'Boolean Checkpast values(Int32)' method, and this method…
-
0
votes1
answer50
viewsObjects Entity Framework
I’m having a question with Entity Framework I have a situation where I want to implement a database structure of an accounting plan, for example: the active current account ID 1.1 is the parent of…
-
0
votes1
answer1256
viewsHow to format`Datetime? ` in dd/mm/yyyy format using Linq?
I have the query below, but while trying to format the field Data_nascimento and Data_exclusao with the .ToString("dd/MM/yyyy") returns me to an error at runtime. The 'System.String…
-
0
votes0
answers137
viewsLINQ Dynamic from DTO - Datetime Filtration
I’m trying to assemble a dynamic filter from a Dtofiltro object that I get filled through the View. My problem is, when I try to filter the results that will be shown on the screen by Mesano, I…
-
0
votes1
answer54
viewsError loading database information to a datagridview via Entity Framework
My project has four classes: public class Manifestacao { public long Id { get; set; } public string NumeroChamado { get; set; } public string DataHoraReg { get; set; } public Cliente Cliente { get;…
-
0
votes1
answer61
viewsLinq to Objects - Performance
When searching for best practice content when using LINQ I came across the following filter situation: // Filtros int idBairro = 8626; first way: IQueryable<TesteConsulta> queryCidade = (from…
-
0
votes0
answers50
viewsselect IN using Entity query
How do I play the following query using Ef core, or in LINQ? SELECT ob.PK_OBJETIVO, ev.NM_EVENTO, ifi.QT_NOTA_IMPACTO, imi.QT_NOTA_IMPACTO, ire.QT_NOTA_IMPACTO, (ifi.QT_NOTA_IMPACTO +…
linq-to-entitiesasked 6 years, 7 months ago woshington rodrigues 11 -
0
votes1
answer22
viewsProblems with select command of Line
The query worked she has 2 questions randomly with the 5 options each. The problem is that my select loads the view described below: public class QuestaoOpcaoModel { public int QuestaoId { get; set;…
-
0
votes1
answer48
viewsProperty with GET (Getteronly) with Iqueryable C#
I don’t know exactly what it’s called when it maps the return in the method like this, but I’ll try to explain, I have the following class for example: public class Venda(){ public decimal Valor…
-
-1
votes1
answer488
viewsHow to perform a Left Join with LINQ C# using my SQL?
Example that works in SQL: select * from Doacoes inner join Projetos on Projetos.IdProjeto = Doacoes.IdProjeto left join Pedidos on Doacoes.IdDoacao = Pedidos.IdDoacao left join Recompensas on…
-
-1
votes1
answer79
viewsLinq to Entities - Count elements of a query referencing two contexts
I have the following query: var query = (from q1 in query1 join q2 in query1 on q1.idGenerico equals q2.idGenerico into q2Left from q2 in q2Left.DefaultIfEmpty() join q3 in query3 on q2.idGenerico…