Most voted "linq" questions
Language Integrated Query (LINQ) is a component of Microsoft. NET Framework that adds native data query (query) functionality in . NET languages.
Learn more…578 questions
Sort by count of
-
0
votes2
answers822
viewsHow to return more than one database Entity in a LIST?
I have two entities, CATEGORY and TRANSACTION, on the bench I also have these two tables. TABELA: CATEGORIA CHAVE: ID TABELA: TRANSACAO CHAVE: CATEGORIA_ID When performed a select for Entity…
-
0
votes2
answers974
viewsHow to make a datagridview C# sort a list (Ilist) by clicking on the grid header?
How to make a Datagridview C# sort a list (Ilist) by clicking on the grid header? For example, I have a list with three fields (id, name, city), when the user click on the column name, I want to…
-
0
votes1
answer71
viewsLoad variable with Split Expressions by scrolling through a list
First I made this code: for (int i = 0; i < vlstAcessos.Count - 1; i++) { if (vlstAcessos[i].DsURLTransacao == "frmANAAguardeProcesso.aspx") transacaoANA = vlstAcessos[i].DsURLTransacao =…
-
0
votes2
answers386
viewsLINQ to Entities does not recognize the 'Boolean Like' method?
I am having this error when trying to make one with query using LINQ to SQL after making the suggested changes: {SELECT `Extent1`.`idcliente`, `Extent1`.`nome`, `Extent1`.`pai`, `Extent1`.`mae`,…
-
0
votes1
answer82
viewsPick different records from two tables
I have a table offline: id int descricao string online int chave string And another table online: id int descricao string chave string How do I select the table fields online which do not exist in…
linqasked 7 years, 8 months ago Italo Rodrigo 4,344 -
0
votes1
answer282
viewsEntity mapping oneToMany with Fluent Nhibernate
Gentlemen, my problem apparently is simple, I must be doing or forgetting something and I just can’t see the error. Can you help me? I have the class Cliente: public class Cliente { public Cliente…
-
0
votes1
answer277
viewsLINQ to Entities x Lambda Expression
What is the difference between LINQ to Entities x Lambda Expression? Still using LINQ to Entities in the Entity Framework or is there something new?
-
0
votes1
answer301
viewsReturn date x days left to arrive
Scenario: Ciclos id name endDate (datetime?) Dice: 1, primeiro, 05/10/2017 2, segundo, 15/10/2017 3, terceiro, 20/10/2017 4, quarto, 30/10/2017 With Line and lambda, I would like to return the dates…
-
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, 6 months ago Thiago Ubiratan 353 -
0
votes1
answer35
viewsError with LEFT JOIN on LINQ
My query is returning as error Additional information: Object Reference not set to an instance of an Object. When I try to make a category that has no product display "(Non-existent)": var lst =…
linqasked 9 years, 2 months ago Kelly Soares 1,181 -
0
votes1
answer141
viewsError when selecting part of a string in the select of an entity using Entity Framework and Linq
I need to assemble a Drop-down with part of the name of a project, which is very large in the database, goes up to 250 characters. For this I made a selector like this: var lista =…
-
0
votes1
answer651
viewsFilter a NULL type in lambda Expression or Line
Hello, my entity To has a long type attribute that can be NULL making relationship with the entity B, by making a filter with a Lambda expression with this attribute to bring all records that are…
c# asp.net-mvc linq asp.net-web-api lambda-expressionsasked 6 years, 7 months ago Thiago Ubiratan 353 -
0
votes0
answers64
viewsQuery on table name by Reflection
I’m trying to make a query in the table, which her name will come by the scope of the method, but does not allow me to use Select(); or Where(); System.Type referenceTableType =…
-
0
votes1
answer45
viewsDoubt when searching for items with Entity
Guys, I have to pick up all the sales items concretized. Every item is recorded with a CART in a sale, in the sales table I have the CART. How do I get all these items? I made this code: public…
-
0
votes1
answer68
viewsLinq XML problems using namespace . net
I am using a namespace at the moment I create my xml, but xmlns is also appearing in the tag below the root, this is hurting me, how can I make 'xmlns' get apernas in the root tag (Tlote_gnre)?…
-
0
votes1
answer34
viewsJOB LINQ to update values in the database!
I have a JOB in which I need to update all the values to the maximum value that exists for a column, but my code is not working. Can someone help me? My code: List<SqlOnlyCostModel> costat =…
-
0
votes1
answer37
viewsNothing value in a query to an xml tag using Linq . net
I have the following xml: <ns1:TRetLote_GNRE xmlns="http://www.gnre.pe.gov.br" xmlns:ns1="http://www.gnre.pe.gov.br"> <ns1:ambiente>1</ns1:ambiente> <ns1:situacaoRecepcao>…
-
0
votes1
answer29
viewsHow to get duplicate items for specific Ids?
How do I get the list of repeating items with the same fpId and eclId? var lst = (from fp in FPIds from et in ETIds from ec in ECIds join eclp in ECLP on ec equals eclp.ecId join ecl in ECL on…
-
0
votes1
answer32
viewsHow to write this query using lambda Linq in c#
The query I have to pass to lamba is as follows: select * from Linguagem inner join Cadastro on Lin_ID=Cad_IDLinguagem and Cad_Situation=0 only coonsegui do until the part of the joint but Where do…
-
0
votes0
answers27
viewsWhat is the difference between the two syntaxes with LINQ?
List<string> esportes = new List<string> { "Futebol", "Voleibol", "Basquetebol", "Natação", "Rugby", "Handebol" }; List<string> resultado = new…
-
0
votes1
answer30
viewsProblem to query inside the second Dropdown
Always enter ajax error: error: function (ex) { alert('Failed to retrieve vigararias.' + ex); } Screen error: Failed to Retrieve Vigararias. [Object Object] View: <script…
-
0
votes2
answers57
viewsName of the Linq Dynamics column?
I have a column that will receive the orderBy dynamically, by example: _context.Tabela .Where(p => p.colunaA.Contains(searchBy) || p.colunaB.Contains(searchBy) || p.colunaC.Contains(searchBy) ||…
-
0
votes1
answer41
viewsQuery n:m using the Entity Framework
My problem with doing a "Many-to-Many" query. Receiving a View ID. In other words, I receive an id from the selected framework. 1 Catechesis has a list of parishes and 1 Parochia has a list of…
-
0
votes0
answers48
viewsTextbox problem for autocomplete
I can not enter the method that makes the query to return the nomes and the id´s of the person. View: <script type="text/javascript"> $(document).ready(function () { });…
-
0
votes1
answer47
viewsCorrect LINQ search syntax in MVC
I built an application with MVC that performs a query in an SQL database and returns it as a table, and now I want to add a search bar to that screen. I’ve already set up my "Index.cshtml" view…
-
0
votes2
answers793
viewsSave XML from a List
I am developing a C# Console Application that loads a List and then writes an XML file with the contents of this List. Class public class Equipamento { public int Id { get; set; } public string…
-
0
votes1
answer64
viewsHow to use SQL LIKE
I’m trying to assemble a string that makes a filter to compare only a piece of a numbering. I tried to make an appeal and looked for several ways to do it and so far I could not. using…
-
0
votes1
answer790
viewsSUM within SUM Entity Framework performance
I made a query with Entity framework and I’m having problems with performance. public static Decimal ValorPrevisto(this ClinicaModel clinica) { return clinica.Contratos.Sum(c =>…
-
0
votes1
answer48
views0.. 1 to 1 modeling in the Entity Framework - Error The Entity or Complex
I’m trying to make a query but returns the error: Additional information: The Entity or Complex type 'WMB.CieloB.Model.Cielotoken' cannot be constructed in a LINQ to Entities query. My consultation:…
-
0
votes1
answer332
viewsJoin several values of type Iqueryable
I am receiving an array of values from my View with the days of the week. Sunday, Monday, etc. I want to compare this array with a string type attribute of my database and store it in a "Iqueryable"…
-
0
votes1
answer875
viewsLinq - Relationship with 3 tables
Good morning. In my project (C# MVC), I need to make a query with three tables, being: Tabcolecao 1 - N Tabvolume and Tabvolume 1 - N Tobacconist Example: I need to present the View as follows: The…
-
0
votes1
answer575
viewsI would like to check in the customer register if the code entered already exists. How do I?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AtFinal { class Program …
-
0
votes1
answer32
viewsLINQ with multiple ON in OR condition?
I’m encountering a problem in the use of LINQ, I don’t have much knowledge of how it does. I have the following code: (from BEN in repositorioBEN.RetornaTodos() join CON in…
-
0
votes1
answer739
viewsLINQ Return from the list is with all the repeated records
I’m having problems performing a select (using LINQ) in a View in SQL Server 2012. The values stored in the bank are as below: ID_Acomp ID_Pessoa Nome Data 26 300 MONTEIRO 01-01-2016 27 300 MONTEIRO…
-
0
votes1
answer88
viewsModify generic method to merge information into classes
I’m a first-time sailor with the Entityframework and I’m working with a class USUARIO who inherits from PESSOA. There are other classes like PESSOATIPO, PESSOAFISICA, PESSOAJURIDICA, etc., the…
-
0
votes1
answer26
viewsError accessing array indices inside a LINQ expression
I am doing a query to search all weather with a certain date, but when executing occurs the following error: An exception of type 'System.NotSupportedException' occurred in…
-
0
votes1
answer142
viewsC# Entity Dbset with DDD?
I have an app C# MVC with DDD and in the repository I’m making the call like this: return DbSet.Include(i => i.Cliente).FirstOrDefault(a => a.ProcessoId == processoId); DbSet-> is in the…
-
0
votes1
answer182
viewsConsultation in Relationship Many-to-Many with LINQ to Entities
I created a database that has two tables called Teachers and Courses. A teacher can teach many courses and a course can have many teachers. I created the table Undergraduates to relate both. When…
-
0
votes2
answers471
viewsHow to leave the json of two or more object classes on the same level in Asp.Net MVC
I have 3 classes being Contact, Sector, Unit so I have Contact with one to many relationship with Sector and Unit generating Json with many layers, making it impossible for Jquery Bootgrid to access…
-
0
votes1
answer344
viewsHow to convert SQL command to LINQ?
I have two classes: Produção { int id, procedimento int, quant int string competencia } bpi { int id, ini idProducao } How to convert the code below to LINQ? select ((sum(procedimento) + sum(quant))…
-
0
votes1
answer83
viewsHow to interpret * in this query
I got a query which, apparently, is simple if it weren’t for the fact that I have these two * Alas, I’m not sure if it’s inner join, left join or someone from the same family. I need to turn this…
-
0
votes0
answers68
viewsQuery 3 tables using LINQ and return a Json object
How do I query the database between 3 tables using LINQ by returning a JSON object following the Structure below ? Public class PedidoGrupo{ int id ; string nome ; public virtual List<Pedido>…
-
0
votes1
answer192
viewsReturn a new object using the Foreach function
Have the following list List<EmployeeTotal> totals = Context.Database.SqlQuery<EmployeeTotal>(query).ToList(); I want to transform all objects in the list totals on a new list of the…
-
0
votes1
answer496
viewsCheck for list records in the Entity framework
I have the following code: var ret = Monitoramento.List .Include(p => p.CD) .ThenInclude(p => p.CargaEntrega) .ThenInclude(p => p.CargaEntrega.Motorista) .ThenInclude(p =>…
-
0
votes1
answer488
viewsDelete a foreach and replace the result in a lambda expression in a method
It’s pretty simple stuff. I have a method that takes a name inside a database and compares it with the parameter passed in the method and be equal, return it in the method, otherwise return a…
-
0
votes1
answer51
viewsDoes Linq generate this ID? How to recover?
I’m doing an automation using Selenium Webdriver and I’m taking all the elements of a Table. I used the code below: var qntd= driver.FindElements(By.XPath("//*[@id='dataTable']/tbody/tr")).Skip(3);…
-
0
votes1
answer104
viewsError when using GROUP via LINQ
I’m trying to perform the query below: var query = from s in db.Crm_Analise where s.cliente_CRM == cod_cli group s by s.TAG into g select new { TAG = g.Key, ATUALIZAÇÃO = g.Max(t =>…
-
0
votes3
answers58
viewsNullreferenceexception error in Join
I created a Join in LINQ to create a List: (from p in listaProcedimento join pd in oListaprocedimentodetalhe on p.codigo equals pd.codigoProcedimento into pd1 from pd2 in pd1.DefaultIfEmpty() select…
-
0
votes1
answer251
viewsLoad list with Entity
The following. I created a context class inherited from DbContext. public class SiloContext : DbContext { public SiloContext() : base("inetConn") { } public DbSet<Produto> Produtos { get; set;…
-
0
votes1
answer236
viewsLambda or Linq brings me all the fields and not only those of expression
Just for learning even, understand the section. I did a lambda of a bank with only 6 fields, like this: public List<LiberacaoDTO> getAutoriza(int idorcamento) { var lista = contexto.Liberacoes…