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
-
1
votes1
answer1953
viewsDynamic Linq Query between two contexts
I’m trying to return the query sql sequinte but without success. SQL= select IDEstado, COUNT(IDEstado) from PessoaEstado w join Nucleo.dbo.Estado e on e.ID = w.IDEstado where IDPessoaMaster = 46…
-
1
votes1
answer594
viewsReturn more than one data list in the view
In my Return View(), is there a way for me to return two or more lists? These lists are the result of a.
-
1
votes1
answer183
viewsError 500 in Asp.Net Awesome Library
I found browsing the internet this library ASP.net Awesome. I found it very functional and easy to use. According to the documentation to use a helper called Lookup, you need to have a controller…
-
1
votes1
answer2070
viewsAssign value to an object property by a list of objects
I have a list of objects: List. Well, this object has three properties, say, cnpj, acao and novaacao. I did a lick or lick and brought me all the results, let’s say two lines. I do a foreach on the…
-
1
votes0
answers53
viewsPage a very large list
Grid in MVC - I have a lot of data to return and I didn’t want to bring all of a single see even why there is paging. How do I get 10 records? Which grid to use together with MVC and Entity…
-
1
votes2
answers104
viewsBatch deletion using Linq
I have a table, which is used in my Model.edmx, with the following fields: ID ID_PROJETO ID_ITEM VALOR How to convert the SQL below into a Linq expression? DELETE FROM TB_RECEITA WHERE ID_PROJETO =…
-
1
votes2
answers766
viewsRemove objects from memory
I have a DataGridView in my project and a timer with refresh 5 seconds. I realized that the system was overloading the memory, as each time I listed the previous data remained in memory. This is the…
-
1
votes1
answer129
viewsIn the table Insert is inserting everything, until what I do not want
When I give a savechanges(), records to all tables and would like just one. How do I do? Tables Acao and ProximaAcao also inserts record. public T_TarefaParceiro geraIdParceiro() { WEBEntities db =…
-
1
votes1
answer945
viewsDoubt about Insert in bank with foreign key using Inline
I have a question, how to insert data in a Mysql table, using English, I have the tables below: I am using the method below to insert: public void inserirCarteira(float cpf, string codigo, double…
-
1
votes4
answers2214
viewsBring a Max(Date) with LINQ
I have this Linq: var resultado = ( from pdv in db.T_PDV from tarefa in db.T_TarefaParceiro.Where(trf => trf.CNPJ == pdv.CNPJ).DefaultIfEmpty() from parceiro in db.T_OsParceiro.Where(prf =>…
-
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
answer130
viewsHow to receive unique data in Asp net mvc
I have the following model called Conta: public int Codigo { get; set; } public string Nome { get; set; } public int Prazo { get; set; } assuming I want to select (without using lambda) and bring…
-
1
votes1
answer311
viewsLINQ Group By with multiple fields in key
How do I include the IdCategoria in addition to the category name in the Console of the first FOREACH? var lst = from p in BDProduto.produtos join c in BDProduto.categorias on p.IdCategoria equals…
-
1
votes1
answer619
viewsHow to concatenate fields in the Line and rename
I made a Burst and it is not working concatenation and renaming it. See: var monta_arvore = (from rup in db.Ruptura from apr in db.Apresentacao.Where(ap => ap.Codigo_Apresentacao ==…
-
1
votes1
answer177
views -
1
votes1
answer118
viewsMake a foreach that does not repeat the same data
I have this foreach, in a table with more than 5000 records. There are only 6 types of business unit. I would like that in the foreach and Ingl, when a type of UN appears, it loads and then does not…
-
1
votes1
answer54
viewsLinq brings result but does not obey Join
We’re getting closer. With this code, it almost worked. Then I switched the Distinct() for DistinctBy() and did not repeat, but still not obeying the IDMotivo. What comes in Linnum does not match…
-
1
votes2
answers2031
viewsProblems with types and conversions when filling a page
That is the mistake: An exception of type 'System.InvalidCastException' occurred in App_Web_fjskumyk.dll but was not handled in user code Additional information: Não é possível converter um objeto…
-
1
votes1
answer157
viewsWhich List Findall method is used in a Datatable
I have the following select below: var Filhos = FluxoWorkflow_ .FindAll(N => N.IdPai.GetValueOrDefault() == dr.IdFluxoWorkflow); I had to change my typed class to a DataTable I’m just not able to…
-
1
votes1
answer206
viewsArgument data type xml is invalid for argument 1 of Len Function
I am mapping a property to the xml database using Migrations. public string Xml { get; set; } this.Property(t => t.Xml).HasColumnName("Xml").HasColumnType("xml"); However, when consulting the…
-
1
votes1
answer196
viewsHow do I put a Count in a string that returns a list
I need to make a count, for the following situation. See the image below, that I have repeated some pharmacies, see their CNPJ(066253003681 and 06626253001476). They are repeated because they are on…
-
1
votes1
answer59
viewsQuery with LINQ, trying to perform a RIGHT JOIN
I need to make the following query through LINQ, using the informed tables: Must return all vehicles where the "Type" has the field "PART" equal to "true", the link of the table "Vehicle" with the…
-
1
votes2
answers78
views -
1
votes1
answer168
viewsDynamic Linq Ordering using System.Linq.Dynamic
I’m trying to sort a list using the library System.Linq.Dynamic, follows the code excerpt: list = db.TABELA.Where(consulta.Colum + ".Contains(@0) ", consulta.filtro).OrderBy("@0 ",…
-
1
votes2
answers365
viewsRecover data from a Linq SQL query with Join
In the presentation layer I call a method consLaboratorio who is in a namespace separate where all access to the data is carried out. This method returns an object MiddleOneReturn with: codeErro (0…
-
1
votes1
answer35
viewsTotal sum with Line
I have no idea how to get the Total value = 755.00 of that select with Linq ? | ID |Qtde | Valor | Total | | 1 | 10 | 23.00 | 230.00| | 1 | 15 | 10.00 | 150.00| | 1 | 15 | 25.00 | 375.00| Total:…
-
1
votes2
answers640
viewsHow to return all records from a table
In my context I have a File table, and another version of the file, so I did with Entity to return a file, and only one version of the file: internal Arquivo GetArquivo(string termo) { using (var…
-
1
votes2
answers342
viewsFilter for the next 90 days ASP.NET MVC
need to make a filter with Line in an entity, this filter should bring all events for the next 90 days. Today’s example: 11/01/2017 until 11/04/2017 (90 days) _con.SiteContexto.AsNoTracking()…
-
1
votes0
answers64
viewsHow to improve the loading of related entities using Linqkit?
Hi, I’m using Linqkit To stack "Expression Predicates", I need to do a "foreach" to load the related entities and this is being very expensive for application because to load 1000 records is taking…
-
1
votes1
answer1633
viewsAdd Datatable C# columns with Linq
I have a DataTable containing a column called SubTotal. I would like to add up the total value of this column. I tested some examples: object sumObject; sumObject = table.Compute("Sum(Amount)", "");…
-
1
votes2
answers1660
viewsSelect Where in LINQ
How to convert code select below in LINQ? select * from producao where id not in (select idProducao from bpi)
-
1
votes3
answers106
viewsFilter per parameter or all
I make an appointment at the bank. I would like to filter the column ID_LEAD by the filter value "if there is" int?(filter.code) or filter all over the world. follows the example of how this in the…
-
1
votes1
answer100
viewsjLln - Make dynamic query by taking 'Select' values
I’m using jLinno to search for in a Array of Objetos I would like this search to be dynamic, taking the values of Selects my example: <select id="firt"><option>Select…
-
1
votes1
answer89
viewsHow to load only the ID attribute in Many-To-One Relationship in EF?
I have two relationships Many-To-One in this class (usuario and projeto): public Atividade() { Projeto = new Projeto(); StatusAtividade = EStatusAtividade.NaoIniciado; TipoAtividade =…
-
1
votes1
answer1045
views -
1
votes2
answers619
viewsHow to get data from two tables in the same column?
I have two tables in the database: Tabela1 Id Nome Sexo 1 NomeA Macho 2 NomeC Fêmea Tabela2 Id Nome Sexo 1 NomeB Macho 2 NomeD Fêmea I would like to have the following result: Id Nome Sexo Tabela 1…
-
1
votes0
answers62
viewsWhat is the difference between the forms of LINQ research?
What’s the difference between: var query = from s in db.DetailsRaWeb where s.cod_cli.Equals(Cod_Cli) && s.tag.Equals(TAG) select s; and this: query = query.Where(s =>…
-
1
votes1
answer195
viewsSelect two attributes from two different tables in a view
I have the model (superclass) Pessoa and the model Aluno public partial class Pessoa { public Pessoa() { this.Escola = new HashSet<Escola>(); } [Key] public int PessoaID { get; set; } public…
-
1
votes1
answer48
viewsError with lambda and fields float
Every time I carry my lambda, I make that mistake: System.Invalidoperationexception: 'The specified cast from a materialized 'System.Double' type to the 'System.Single' type is not Valid.' This only…
-
1
votes0
answers48
viewsConvert Anonymous Object
How can I convert an anonymous type object to a known class using Linq version 4 with Entity Framework in C#?
-
1
votes1
answer71
viewsHow to use SUM in a string field by converting the value to int?
I have a table that has a field PA that is string, it stores a 10 digit number and I can’t change the type of it because it references another table. I’m trying to add this field like this: Int32…
-
1
votes1
answer58
viewsHow do I recover filters from a query?
Hello. You can find out which filters, sorters, etc were used in a query? Example: public class Program { class Produto { public int Id; public string Nome; public Produto(int id, string nome) {…
-
1
votes2
answers317
viewsRandom list in Query Linq to Entity C#
I would like to get a list of 3 objects within a query Link. var listaPessoas = from i in this.Context.CreateObjectSet<listaPessoas>() select i; ... listaPessoas = listaPessoas .Where(x =>…
-
1
votes2
answers324
viewsFirstordefault, Singleordefault, Elementatordefault
What is the difference between the elements FirstOrDefault and First, SingleOrDefault and Single or ElementAtOrDefault or ElementAt. When to use with and without the Default?…
-
1
votes1
answer95
viewsPerforming a query C#
I have a controller where I make a Select to get a list, but it returns empty. public IEnumerable<Check> GetUserByNumberOfregistration(int numberOfregistrationUser) { CheckContext contextObj =…
-
1
votes2
answers141
viewsSelect with Linq set the first characters in Where
How can I define in Linq the same that I define in clausular Where do sql server in the form below .. select * from tb_CentrosCusto cc where cc.Clasificacao like '1.4.1%' In other words, I’m just…
-
1
votes2
answers266
viewsHow to use Distinct() or Groupby() in a list that returns an anonymous type?
I’m doing a select on the bench to bring the IdNavio and Navio, but I don’t want to bring the repeated. I’m trying to use the methods Distinct() and GroupBy(), but they’re not working, I’m using the…
-
1
votes2
answers112
viewsHow to run a subconsultation on LINQ C#?
How to run a subconsultation on LINQ C#? SELECT ap.ID FROM Aplicativo AP WHERE AP.Tipo IN (2,6) AND AP.ID NOT IN (SELECT filhoID FROM relacoesobjeto WHERE filhoclasse = 555)…
-
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
votes1
answer55
viewsConversion of a LINQ query into methods
The following query in LINQ (with query) below is used to list all vendors that have an account (relationship 1 to 1): from f in fornecedores join c in contas on f.ID equals c.FornecedorID select f…