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
answers366
viewsReturn an object from two or more tables to the fields
I have done some posts on Rest and Lambda, and to give a close on this subject(I hope), I have a question. A colleague here at the site recommended that I create a DTO and bring the database data…
-
0
votes1
answer44
viewsXML query with Linq
I need to read a specific part of an XML (highlighted in red), and for this I am using LINQ. I’m using the following code, but I believe I didn’t write it the right way. IEnumerable<string>…
-
0
votes1
answer230
viewsC# Join 3 tables using Linq?
I’m picking it up to learn C# and I’m picking it up at some points. I have 3 tables. Follow the models public class Tag { [Key] public int ID_Tag { get; set; } [Required(ErrorMessage = "Preencha o…
-
0
votes2
answers52
viewsSQL/LINQ vs. Data to feed
I’m trying to generate a query in VS2015 with Linq (here, I exemplified in SQL, to speed up my tests right in the database) that returns the data grouped and counted from 6 months ago, it happens…
-
0
votes1
answer118
viewsQuestions on how to identify an object in the collection
I’m studying C# and I’m having some questions.. The project I’m doing is a fictional gallery system that registers the Artists, Curators and pieces of arts. I created the abstract class "Persons"…
-
0
votes1
answer41
viewsSubmitchanges() does not update data in Linq
internal bool AlterarCargo(string login, string Categoria) { db.Log = Console.Out; //tentei ativar para ver se encontrava o erro mas não ajudou nada. var categoria = from x in db.Categorias where…
-
0
votes2
answers157
viewsCreate a Join between two classes in my repository
I have a repository for my class PessoaCadastro that relates to the class Pessoa. I need to create a method GetJoinAll(...) show me all the table records PessoaCadastro that are related to Pessoa…
-
0
votes2
answers84
viewsWays of connection in ASP . NET
I’m a beginner in ASP and C#. I have doubts and this is the real reason to ask here. Before you have to read the politics of questions understand that I am a beginner and I really need help. I have…
-
0
votes0
answers235
viewsC# & Mongodb - How to filter in child document?
I am starting my adventures in Mongodb and I have a problem specifically with the filtering of documents. The model of my application: public class MatrizCurricular { [BsonId] public ObjectId _id {…
-
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
votes1
answer81
viewsVery slow query to export in excel
I created a method to export a few columns to xls and it is very slow the process, it takes about one minute to do the whole process. public void Download(string datainicio, string datafinal, int?…
-
0
votes2
answers159
viewsHow to use the Where clause with Inno?
I need to make a Join between the person and people tables so that the core Entity Framework brings a corresponding record. Let me be clearer: In the personal tableentity, I sort my register of…
-
0
votes1
answer102
viewsWhere de query using multiple list properties
I have the following scenario public Teste[] GetTestes(List<TesteDTO> testeDTOs){ IQueryble<Teste> query = GetAll<Teste>(); //where ... } public class Teste() { public int Prop1{…
-
0
votes1
answer139
viewsGrouping in LINQ with multiple entity records
I have a LINQ query that averages a list of Notes grouped by risk sources. var mediaControles = await (from ac in _context.AvaliacaoControle join c in _context.Controle on ac.ControleID equals…
-
0
votes2
answers250
viewsHow to sort and list only 5 items from a list?
You see, I am developing the Dashboard of a web system, in one of the filters I should list the 5 main customers and sort them by higher value of the sums of total of issued bills. I’m already able…
-
0
votes0
answers45
viewsHow to turn my query into a Linq query?
I need to mount this query in Entity select ped.Id, prot.Prot_numero as Protocolo, ori.Descricao as Sistema, cla.Id as Equipe, cla.Descricao as Finalidade, forn.Nome as Fornecedor from Pedidos ped…
-
0
votes1
answer91
viewsC# - Asqueryable - Condition (Linq - Lambda)
In this method, I populate my 'rule' variable with all rules coming from Select, however, I would like to filter only Status = True. How to do this? public async…
-
0
votes2
answers154
viewsWhy . all in an empty list returns true?
I was having an error in a business rule, and when investigating, I arrived at the following code snippet, the intention of which is to verify that all the processes on a list are active: return…
-
0
votes1
answer47
viewsHow to merge sublists from a class and return the result using Linq and C#
Hello, I am working with c# and I have the following situation: I have 2 classes in the system, Order and ProductSold; Order contains as property a List<ProductSold>; In certain Viewmodel, I…
-
0
votes0
answers171
viewsHow to define the order of a list dynamically using Linq and C#
Hello, I am creating a method so that I can return a list of people where, I pass the column that should be ordered and whether this is increasing or decreasing. Thus: public async…
-
0
votes1
answer61
viewsExtraction of different data from two object lists
I am working on a WEB API and need to remove some values contained in one list and which are contained in another. To be better illustrated would be the equivalent of removing the data from a list…
-
0
votes1
answer415
viewsUsing Elements like "Not Exists" and Sub Query in LINQ, LAMBDA EXPRESSION and Nhibernate
Good Morning, I have a query to be executed in my database, however, here in our projects we use Nhibernate as a ORM tool. I’m having difficulty passing this SQL query to a syntax used with…
linq lambda-expressions nhibernate fluent-nhibernate linq-to-sqlasked 6 years, 2 months ago Italo Angelo 3 -
0
votes0
answers161
viewsGet value from an entity via navigation property
I have a question that seems basic, but I’m racking my brain to solve. How can I get the value of an entity attribute via Properties Navigations? For example, I have the classes: public class Budget…
-
0
votes1
answer75
viewsGenerate list dynamically with Linq
I have an API that uses Dotnet’s Dynamic to generate billets. The documentation is as follows: dynamic endpoints = new Endpoints("client_id", "client_secret", true); var body = new { items = new[] {…
-
0
votes2
answers1395
viewsHow to pick up items from a json in c#
After almost 3 days trying to implement I did not succeed. I have the following json: { "code": 200, "data": [ { "id": 1, "type": "charge", "custom_id": "1208", "status": { "current": "new",…
-
0
votes1
answer93
viewsPass list to model
I have a query that returns me a list this way: var list = db.Comentario.Where(d => d.GrupoTrabalhoId == Id).OrderByDescending(s => s.DataComentario).ToList(); After this query, she will…
-
0
votes0
answers23
viewsHow to create the event for a textbox in Runtime?
foreach (SobralFoodContext.Produto produtos in categoria) { string str = "<div class=\"col-sm-4\"><div class=\"card\"><div class=\"pricing-list dark-pricing\"><div…
-
0
votes2
answers65
viewsHow to do a parallelism or asynchronous call in a lambda
I have this query qry.ForEach(q => { var product = new Product(); product.CategoryId = q.CategoryId; product.AuthorizeMaximumPercentageAlteration = q.AuthorizeMaximumPercentageAlteration;…
-
0
votes1
answer49
viewsReturn of a single element from a list to a LINQ
I’m taking elements from a list and I can’t erase the elements, I have to return them all. I found a problem at the end of this query, where you have the comment //Erro…
-
0
votes1
answer73
viewsdifficulty making Foreach lambda in a query
I have this query var qry = _productRepository.Table.GroupJoin(_categoriesRepository.Table, p => p.CategoryId, c => c.Id, (p, c) => new { Product = p, Categories = c.DefaultIfEmpty() })…
-
0
votes1
answer94
viewsProblem searching (Firstordefault) - Linq
I’m having a problem conducting the following search: var estDel = bdprincipalEntities.unidades .FirstOrDefault(x => x.uni_codigo == uni_codigo && x.Emp_codigo == Emp_codigo); the field…
-
0
votes1
answer100
viewsVirtual property is not instantiated in lambda
When I took a code to improve performance I had the following. A method GetAll() this method populated a var. It was made a foreach in this var and was assigning the appropriate values. It happens…
-
0
votes0
answers39
viewsC# - Comparison of date with LINQ does not bring the expected result
We have an Oracle database with a View. We have to take the total harvested cane by adding the column QT_LIQUIDO according to the day. We made the code in C#, but it is with an unexpected behavior.…
-
0
votes1
answer55
viewsLeft Join - Linq is bringing Duplicate Value
Hello, I have a print method, which makes several left join, it is bringing the values I want, but some of these values are coming duplicated, as shown in the images: Table TabelaImposto: select…
-
0
votes0
answers65
viewsMethod is not recognized within select
The query works perfectly, but when I include the Getqtdecpossible method that returns an integer, to get the possible amount and not need to make other error queries. What I do wrong? var fpcpAdd =…
-
0
votes1
answer30
viewsWrong value return
I am creating a list within another one as follows: var playerGames01 = new ObjectGamePlayerMoviments(); playerGames01.Game = new List<Games>() { new Games { PlayerMoviment = new…
-
0
votes1
answer37
viewsIcollection property in class is not instantiated
I have the product class and in that class I have this property public virtual ICollection<CspProduct> CspItems { get; set; } Here we take the products var products =…
-
0
votes1
answer123
views'Iorderedequeryable<Condominium>' does not contain a Definition for 'Tolistasync'
I’m getting the following error: as in the image below: In that part of the Code: public async Task<IEnumerable<Condominium>> FindCondominiumAllAsync() { return await FindAll()…
-
0
votes1
answer59
viewsProblem comparing 2 lists
I have a problem, I need to make a filter with a list of strings that comes as parameter with a icollection, the visual studio accuses "Cannot Convert from List to Unidadefederativaforedor" What…
-
0
votes1
answer44
viewsCreating a comeback With a sublist
I am trying to write a query in Latin to solve the following problem: I have a Student List that I have student data like Id, Name, Enrollment, Cpf... In another entity I have the notes where the…
-
0
votes1
answer42
viewsDoubt in the Linql
I have 2 tables: one for product and another with a conversion list. Could I make a single connection to the database without having to go to the bank several times? For example, to each product I…
-
0
votes2
answers45
viewsFind a lower value of a collection, according to one condition
I have two collections: A and B as List<int>, both of the same size N. In collection A, are the designs. In B, the offerings by the project. Illustrating: projects[5, 1, 4, 5] offers[8, 7, 6,…
-
0
votes1
answer32
viewsHow to filter a database item through a List field?
I have the entity MessageEntity which contains several sessions (SectionsEntity) which in turn contains several calls (TreatmentEntity). I need to bring the messages, filtered by your Id, filtered…
-
0
votes0
answers23
viewsPredicate with a list of 2 values matching pairs
Hello, everyone. I have an SQL with filter that the user has the possibility to inform several "cost centers" and "cost sub-centers" combined. That is, in practice, it would be a list with 2 values…
-
0
votes1
answer44
viewsRefactor code using LINQ in C#
I need to refactor this method in C# and replace these 3 foreach with something smaller using LINQ: public List<Ponto> Filtrar(IQueryable<Ponto> pontosFiltrados, List<Usuario>…
-
0
votes1
answer61
viewsC# LINQ Join with OR condition?
I need to write this SQL in Linq, but in that condition JOIN is what gets me. SELECT * FROM Boleto_Retorno AS BR LEFT JOIN Recebimentos AS R ON SUBSTRING(BR.CH_NossoNumero,1,11) = CASE WHEN…
-
0
votes1
answer23
viewsIdentical objects with same value fields returning different C#
Identical objects with equal fields returning different when comparing with Equals or == var oldPayments = orderNotTrack.Payments .Where(p => p.Status == Status.Activated) .Select(p => new…
-
0
votes0
answers13
viewsMultiple sorting in Datatable with Serverside
Greetings. I have a table generated with the help of the Plugin Jquery Datatable with the ServerSide enabled and running a Script from the server side ASP.NET. Only that I need this table to be…
-
0
votes1
answer41
viewsHow to filter a List record within another list c#
I have a class of App where in that class contains a ICollection<Comentarios> Now I need to filter ALL comments who have Status == Aprovado, where this Status is an Enum. I tried to do it this…
-
-1
votes1
answer106
viewsDoubt in the construction of WS REST(Contract)
Gentlemen, I took an example in the book of john Sharp(microsoft press) to build a REST and came a simple doubt, but a doubt of good practices. He uses the Northwind BD. He creates a Class Library…