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
-
3
votes2
answers560
viewsHow to improve the performance of the Linq query?
I have the consultation below var f = (from l in fpcList join fpp in FPP on new { l.fpId, l.etId } equals new { fpp.fpId, fpp.etId } join fpcp in FPCP on fpp.fppId equals fpcp.fppId select new {…
-
3
votes1
answer94
viewsGrouping of values
I have an application that generates the following results: I would like to know how I can arrange the object in only 1 line, say have only one date, and within the date have the schedules, to have…
-
3
votes1
answer30
viewsHow to join sublists with Linq
Imagine I have the following classes: public class Pedido { public int PedidoId { get; set; } public List<ItemPedido> Itens { get; set; } } public class ItemPedido { public int ItemPedidoId {…
-
2
votes1
answer66
viewsExpression inside a lambda gives error
I created a lambda and tried to create an expression or other. With or(||) it didn’t work. Then, instead of || I added Where. Is that right? This way now: var resultado = db.T_CRM_StatusPDV .Where(a…
-
2
votes1
answer820
viewsHow to create a query with Union using Nhibernate
I need to implement a query in nhibernate make a union between 2 tables. In sql, it would be something like that: SELECT T1.Id AS ID FROM TABELA1 AS T1 UNION SELECT T2.Id AS ID FROM TABELA2 AS T2 I…
-
2
votes2
answers495
viewsLambda Expression X
Speaking in terms of overall performance (speed, integrity and etc...), using English expressions to query database, is better in the above terms or depends on?
-
2
votes1
answer295
viewsError while reading XML
When I try to read the xml, return it to me: {System.Linq.Enumerable.WhereSelectEnumerableIterator<System.Xml.Linq.XElement,SSP.Class.ListaConsulado>} XML: <?xml version="1.0"…
-
2
votes2
answers608
viewsUse of the Ienumerable
I saw an example in another post about the use of IEnumerable var ent = new EntFuncionarios(); IEnumerable<Funcionario> funcionario = ent.Funcionarios; IEnumerable<Funcionario> temp =…
-
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…
c# entity-framework linq linq-to-entities linq-to-sqlasked 10 years, 2 months ago Eduardo Freire Jr 21 -
2
votes1
answer849
viewsData conversion in types such as int and double
I’m having trouble making data conversions from a database, for example I perform a query to the bank like this: carteira ca = bc.carteira.FirstOrDefault(obj => obj.cpf == cepf &&…
-
2
votes1
answer741
viewsManipulating Listview C#
I have a Listview that displays the data on the screen and has several rows and columns. For example: Cl1 | Cl2 | Cl3 L1 aa | bb | cc L2 ab | bc | cd L3 ac | bd | ce I wonder, if you have any c#…
-
2
votes1
answer2238
viewsError in the query
I’m trying to make a query in the table below, from my database. This query is performed through the method below: public void compraAcoes(float cepf, string codigo, int quantidade) { string cd =…
-
2
votes2
answers72
viewsExpression does not bring results, but there is data
This is my direct sql query. select c.de_cnpj, c.DT_TransacaoV from T_CRM_StatusPDV c join T_PDV p on c.DE_CNPJ = p.CNPJ where DATEDIFF(DAY,c.DT_TransacaoV,GETDATE()) > 45 This is my lambda…
-
2
votes1
answer116
viewsPlace a decision control inside a lambda expression
I’m building this consultation: private List<string> pegaInformacaoParceiro(string _osparceiro, string _cnpj) { List<string> lista = new List<string>(); WEBEntities db = new…
-
2
votes1
answer163
viewsDoubt filter with Line, ASP NET MVC
I have a question on a filter using Linq, I have a critical object Inside criticism has a ienumerable I need to return a list of criticisms that the status of the last critical move equals 2 But the…
-
2
votes1
answer240
viewsJoin for field search
I asked a question with another user but I do not know what happened that I could not recover the information and I had to create another one now. Anyway, I wanted to create a search field and I was…
-
2
votes1
answer659
viewsShow null results through LEFT JOIN with Linq!
I have an SQL query: SELECT A.Codplano, A.Secao, A.Setor,A.Subsetor,A.Contato, ISNULL(B.Subord,'NÃO LANÇADA')AS Situacao FROM vwPLANODIN A LEFT JOIN LANCADA B ON A.Codplano = B.Subord and B.Data =…
-
2
votes1
answer159
viewsApply function to all list elements using VB.NET
Is there a function/module for an object of type List in VB.NET that is similar to array_map() of PHP? The idea is to create a new variable with the elements that satisfy a certain condition. I have…
-
2
votes1
answer1223
viewsComplex query when passing parameters
I need to make a query, but I’m having a hard time. I have 5 filters on the page. Three of them come from three dropdown (select). I can only consider select if the text in them is different from…
-
2
votes1
answer80
viewsFilter by group and minimum value
I have the following table: ********************************* * IdPessoa * DataVen * Observ * * 10000000 * 01/01/15 * Teste1 * * 10000001 * 01/01/15 * Teste2 * * 10000000 * 01/01/12 * Teste3 * *…
-
2
votes1
answer97
viewsQuery to SQL database in text saved by Tinymce
I am using Tinymce to edit texts on my website. When I search a word with accent. Ex.: análise, query does not find why the database is saved in HTML análise. I am using ASP.Net MVC with…
-
2
votes1
answer60
viewsProblem - Linq SQL Server: Unwanted query in database when assigning value in a database derived field
All right, guys I have the following problem: I have the method below that only has the job of updating a field in the database, the class t_sap_log_jobs that is passed as parameter was created…
-
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
answer134
viewsDefault value for Datetime column
I have a table that has the field DataRegistro of the kind Datetime. I am using Entityframework to generate the database (I am not using code first) add the property Computed for the column to be…
-
2
votes3
answers131
viewsLINQ Anonymized Type as parameter
I am trying to create a method that receives an anonymous type (LINQ query) (Please correct me if the term tipo anônimo (anonymous types) is incorrect) MinhaLista (produtos.Select(p => new {p.Id,…
-
2
votes1
answer55
viewsSql generated by Linq
Hello, I would like to know how to see the sql code that a String expression generates to be executed by ADO.Net. I am using Nhibernate as a ORM framework.
-
2
votes2
answers146
viewsMapping a List<long> in LINQ to SQL - Windows Phone 7.1
Problem I’m starting an application for Windows Phone 7.1, and I’m implementing the database, only I came across a situation that I couldn’t find any example of similar situation to try to solve,…
entity-framework linq windows-phone orm linq-to-sqlasked 10 years, 3 months ago Fernando Leal 9,770 -
2
votes4
answers582
viewsEntity Inner Join in LINQ
I wanted to make an Inner Join so that I get a list of the names of Logins from the Integer List of UsuarioID class LoginsAtivos. public class Login { public int ID { get; set; } [Required] public…
-
2
votes1
answer156
viewsWhat is more advisable? Perform the query through a list or directly in the database?
I have to perform a consultation where I need to do 4 INNER JOIN and still use WHERE in various fields. What is most advisable? Conduct the consultation in this way? using (DbContexto db = new…
-
2
votes1
answer156
viewsNot In Linq Sql Entity Framework
I need to do Nessa research, but presents the error: ambiguous Invocation. public List<Notification> Get(List<UserVisualization> item) { return db.Notifications.Select(o=>…
-
2
votes2
answers2268
viewsWhat is the difference between Tolistasync() and Tolist()?
What difference between ToListAsync() and ToList()? As in the example below, what is the difference between one and the other? using Modelo.Classes.Contexto; using System.Data.Entity; using…
-
2
votes1
answer2765
viewsEntity Framework Left Join
Seeing the question Left Join with lambda Groupjoin and with condition, I have doubts about the way I do Left Join with Linus Having the following entities public class Cidade { public int CidadeId…
-
2
votes1
answer529
viewsHow to concatenate properties of a single List<> with LINQ?
I need to concatenate two properties of each item on my list, in the example below it works but I would like to know how I can do the same thing using LINQ instead of foreach? public partial class…
-
2
votes1
answer111
viewsDoubt about JOIN of LINQ
Is there a right order to use Join? For example, I have two lists: Categories and products, should I first use the from clause with Categories or Products? And then in Join? Example: var stockQuery…
-
2
votes1
answer729
viewsSearch data from related tables
I know that to return the values of a directly related entity in the bank is done so with LINQ: List<Usuario> lista = banco.Usuario.Include("Tipo").ToList(); But how can I get the data from…
-
2
votes3
answers842
viewsCheck two or more occurrences of a listed element (lambda/Linq)
I have the following list<t> listCard; within it I have the following values: [0]:7720890002560 [1]:7720890002560 [2]:7777777002560 [3]:7720890002560 [4]:7720444402560 [5]:7720777002560…
-
2
votes1
answer341
viewsHow: Fill Object Collections from Multiple Sources
I would like a help in passing values to my property private IEnumerable<OrderDetail> orderDetail;. I would like to fill it in, but I have already looked for some examples and I have not found…
-
2
votes1
answer147
viewsMake calculation using LINQ
I am developing a program in c#. In it I have three tables: produto { string idProduto; string descricao; } entrada { string idProduto; int quant; } saida { string idProduto; int quant; } and I want…
-
2
votes2
answers2051
viewsMerge two distinct lists using LINQ
I have two classes, Cliente and Endereco, where the client has 1 or more addresses, so it is a list of objects: class Cliente { public string Nome { get; set; } public string Cpf { get; set; }…
-
2
votes2
answers180
viewsField sorting of Join with Line in Mysql (C#, MVC)
I have the following query: query = from p in db.pessoa join f in db.pessoa_origem on p.Pessoa_Origem_Id equals f.Id join s in db.pessoa_status on p.Pessoa_Status_Id equals s.Id join c in db.contato…
-
2
votes1
answer468
viewsLeft Join in LINQ
I have the representation of 2 classes. first class: using System; using System.Runtime.Serialization; namespace WebService { [DataContract] public class PessoaDados { private Nullable<int>…
-
2
votes2
answers246
viewsString for Keyvaluepair using LINQ
I am receiving a string in the format "N1N2S3S4L5L6O7O8X" and I need it passed to a KeyValuePair or for a NameValueCollection. Where the key is the letter and the number the value. { N, 1 } { N, 2 }…
-
2
votes3
answers393
viewsSort children in consultation Linq
I’m having trouble making an ordination in a query where I have to sort the children by the ID, Follow the Source. public Grid GetByOrderGridData(long id) { var query = from c in…
c# asp.net-mvc entity-framework linq lambda-expressionsasked 7 years, 7 months ago Thiago Ubiratan 353 -
2
votes1
answer1277
viewsHow to do Union all in LINQ?
I need to execute the command below using Linq: SELECT cnes, cmp, cbo, profNome, pa, sum(quant) total FROM bpai group by pa union all select cnes, cmp, cbo, profissional, pa, sum(quant) total from…
-
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
answer55
viewsA problem to solve with English expressions
I did this, to return a list. It turns out to be an error, saying that there is no way to transform an anonymous expression into the past type (object). public List<Liberacao> PegaLiberacao()…
-
2
votes2
answers2085
viewsLINQ Group By with multiple fields
I am trying to return fields after a merge between collections, but am getting the following error: foreach statement cannot Operate on variables of type 'Anonymoustype#1' because 'Anonymoustype#1'…
-
2
votes1
answer168
views -
2
votes2
answers3604
viewsSpecified conversion is not valid
I’m making an appointment with LINQ in the DataTable in that code snippet. I have to check if a link already exists for a registered person in the database. My query using the LINQ is working…
-
2
votes1
answer158
viewsLINQ TO XML Query with Optional Widget
Hello folks I’m having a question to display the data of a file XML through a consultation LINQ , the problem is that I am trying to consult the data of the person but the mandatory filling and name…