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
answer85
viewsHelp with Querie in Linq C#
I have a message table in the following scheme: Id | osID |Interessado | Remetente | Destinatario | Msg -------------------------------------------------- 1 | 2 |João | João | Maria |bla bla bla...…
-
1
votes1
answer44
viewsHelp with Linq Method using group by Dinâmico
I need to mount a dynamic graph from a filter panel and two fields select that can be crossed. I already have the structure that goes to the graph and how I need to return from backend. In the case…
-
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
votes0
answers213
viewsAdd new values to an already filled Linq variable
I made that Lambda/Linq: var qry = _productRepository.Table.GroupJoin(_categoriesRepository.Table, p => p.CategoryId, c => c.Id, (p, c) => new { Product = p, Categories = c.DefaultIfEmpty()…
-
1
votes1
answer45
viewsHelp in riding a lambda from a foreach
I have this foreach: foreach (var row in responseObject) { if (row.CDOrigem == request.CentroDeDistribuicaoId) { if (row.FaixasPreco == null || row.FaixasPreco.Count() == 0) { var uniqueItem = new…
-
1
votes0
answers107
viewsHow to put one more condition in the Join on clause in a Linq/Lambda query
This query I run in the bank and is working as it should select rci.markuppercentual from resellercatalogitem rci join [Order] od on rci.ResellerCatalogId = od.ResellerCatalogId join OrderItem oi on…
-
1
votes0
answers165
viewsLINQ return with repeated values
I’m having trouble with a consultation within my application. The values returned by my query are repeated, the same value appears 407 times, when the right one would have to be 407 different…
-
1
votes2
answers95
viewsProblem with LINQ
I am converting PDF to TIFF and converting page by page to a temporary folder and at the end I will fetch those files to join them as in the original file. My code is as follows: (I used what is in…
-
1
votes2
answers90
viewsProblem with database query by date using Line and Entity in C#
I have the following appointment at the bank; consultas = ctx.Consultas.Include(c => c.Cliente).Include(p => p.Procedimento).ToList(); which works perfectly, but I want to include a Where to…
-
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, 6 months ago Daniel Silva 11 -
1
votes2
answers64
viewsLower and higher value within Objects with the same date
I have the following Json: { "cod": "200", "message": 0.0055, "cnt": 40, "list": [ { "dt": 1560319200, "main": { "temp": 15.15, "temp_min": 14.49, "temp_max": 15.15, "pressure": 1021.11,…
-
1
votes1
answer89
viewsAm I required to use a repeat loop if my LINQ query returns only one object?
My class: public class Carros { public int ID { get; private set; } public string Atributo2 { get; private set; } public int Atributo3 { get; private set; }}} Suppose the ID attribute could not…
-
1
votes1
answer54
viewsHow to use Join or Aggregate in SQL query
When performing the query in a given table, numOrc is a list that may contain one or more values. So I needed to concatenate these values into one string, using ; as a limiter. So I tried: var model…
-
1
votes1
answer119
viewsConvert Iqueryable to a type
I made that code OrderItem itens = new OrderItem(); var items = _orderService.GetItemsFromOrder(orderId); itens = items.Where(x => x.CurrencyCode == 23).Select(s => new OrderItem { ProductId =…
-
1
votes1
answer81
viewsReturn lambda value and not lambda mounted query
I did that lambda OfferUri = OfferUri.Select(s => s.Items.Where(a => a.SubscriptionId == s.Id).Select(n => n.Id).FirstOrDefault()).ToString() and when I see what she returns to me, I have…
-
1
votes1
answer369
viewsLinq - filters between dates
I have a method which returns records from the database filtered between dates, and is built as follows: public List<ProcessosInformacoesAnexos_Model> DevolveTodosAnexos(DateTime dataInicial,…
-
1
votes1
answer44
viewsProblem in LINQ Query
In my job I need to return a list of a query LINQ. I have an expression that depending on some conditions she adds up Where to return this function. Follow the code: public HttpResponseMessage…
-
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…
-
1
votes2
answers2067
viewsMerge two lists c#
I have 2 lists and would like to join them in a single list to be listed. I created two lists because both present different conditions of the query and I could not relate them in a single list.…
-
1
votes1
answer101
viewsBirth date validation with LINQ
I am doubtful to conduct a consultation. I need to list in this query only the offers that are within the age group listed in view in the fields IDADEMINIMA and IDADEMAXIMA passing only the…
-
1
votes1
answer53
viewsPlace only one item per line in a Listbox
my listbox is putting two or more items in the same row when it fits. How can I force it to put an item per line? Follow the code below: html <asp:ListBox ID="OC02_SERV_SOL" runat="server"…
-
1
votes1
answer111
viewsC# - LINQ ERROR "The data type text and varchar are incompatible with Equal Operator"
I find the following error when trying to update a table: the data type text and varchar are incompatible with Equal Operator. I have done several searches and most indicate the same solution:…
-
1
votes1
answer31
viewsError when performing query with Linq Groupby in C#
I need to select the Groups previously registered, bringing data not repeated. However, an error is returned when performing the query in the table Point of Attendance, where the countryside Group…
-
1
votes1
answer76
viewsConcatenate two variables into one using LINQ
Through LINQ I make a query in the database in the fields CPF and CNPJ table People and need to assign these two table fields to a single variable Document to display on screen. According to the…
-
1
votes0
answers35
viewsPerforming Groupby with Linq?
I’m trying to perform a Groupby but I’m not getting it. Always returns an Exception that I’m not able to solve. How do I solve this problem ? LINQ public ActionResult MeusConcursos(){ Usuario…
-
1
votes1
answer39
viewsList of objects generating string
I have an object list Person that contains a list of Endereços. I would like to print this person with the addresses on string. var pessoa = new Pessoa() { Nome = "Jão" }; var e = new Endereco() {…
-
1
votes2
answers80
viewsC# - Loop no while
I have a C# function that checks if a download has been completed by referring to whether the file exists .crdownload is true. If this does not exist, I assign a true boolean to the while variable,…
-
0
votes1
answer351
viewsQuery Dynamic Linq
I need to create a dynamic query, where the DayOfWeek.Monday is dynamic, as I can define it? DataClassesPDataContext pe = new DataClassesPDataContext(); var qry = from p in pe.R join q in pe.V on…
-
0
votes1
answer116
viewsDismember date to load javascript
I have in BD a Datanascimento field, where it is gurdada in YYYY-mm-dd format. I have a javascript function that scans the table by last CPF. If there is registration for the CPF, then it assembles…
-
0
votes2
answers4814
viewsForeach within a cshtml(view) from a controller
I made a code using Linq and jQuery. Turns out you’re giving me a problem I can’t solve, which is creating a Treeview dynamically. Then I had another idea. To do the foreach right in the View…
-
0
votes1
answer404
viewsWorking with Entity Framework, Multithreading and SQL Server in C#
I’m using the Entity Framework and Multithreading on a project C# and I am going through problems of connection with the SQL Server. Well, I wanted to improve the speed of some data searches for a…
c# sql-server entity-framework linq multithreadingasked 10 years, 1 month ago Vinicius Botelho Bizarri 1 -
0
votes2
answers623
viewsDoubt on how to select a record via Inq
I have a chart, where I only record scripts. There is a field, where I separate whether it is technical script or central script. There is a field TipoScript char e is "C" or "T". This table was not…
-
0
votes1
answer338
viewsCreate a condition within a Linq
I need to make a comparison to set the value within mine select new. I’ll try to explain it better. var tipo= from t in p select new { t.Key, t.Value, }; return Ok(tipo); I wanted to buy if t.key ==…
-
0
votes1
answer309
viewsLeft Join on the Linq is giving error in more than two tables
I did that last breath: var resultado = ( from pdv in db.T_PDV join tarefa in db.T_TarefaParceiro on pdv.CNPJ equals (tarefa.CNPJ) into _trf from g1 in _trf.DefaultIfEmpty() join parceiro in…
-
0
votes1
answer66
viewspick up customer with certain types of purchases
I have these tables: Sales : Idvenda(int)PK, Datavenda(Datetime), Qdeitem(Decimal), Valuation(Decimal). Iditem(FK),Idcliente(FK) Item: Iditem(int)PK,Descricao(Varchar),Valoritem(Decimal)…
-
0
votes1
answer2527
viewsHow to show database data in Textboxes?
Hello! My scenario is as follows: I am developing a web application in C# ASP.NET, and I am having some difficulties to bring the database data (via LINQ to SQL) to the page controls. Below one of…
-
0
votes1
answer604
viewsProblem updating database data using LINQ to SQL
I am developing a C# ASP.NET application in which I search for certain database data, play them in a form, and by clicking 'Save', I want the bank to save the changes I made. I am using Linq to SQL.…
-
0
votes1
answer78
viewsSave fk right after pk is generated with Entity
I have a system and this system has some tables that are associative. As soon as I write the main table in the comic book, I need to make sure that that new generated PK is recorded in three other…
-
0
votes1
answer615
viewsTake Model in View with values from the database
I have that class: public class MontaArvoreAcao { public int IDRuptura { get; set; } public DateTime DataRuptura { get; set; } public int IDMotivo { get; set; } public string Motivo { get; set; }…
-
0
votes1
answer210
viewsNest <ul> tag in another <ul> tag with foreach
I have this foreach, which I did with your help here at SOPT. I cost to make it work, but it worked. Only I did it with just one knot. What I’m going to need is this. I have a father knot, inside…
-
0
votes1
answer278
viewsGrouping in foreach and view does not work
I created and set a variable to control the following. My LINQ returns 5,000 lines today. This variable, it’s there to avoid repeating the same thing, like. Let’s say Linus gives me 400 ID=1 motif.…
-
0
votes1
answer662
viewsLINQ with Left Join and Multiple Keys
My LINQ query does not give error but does not show any result. Where I made a mistake? using (var db = new MyEntities()) { var result = (from dc in db.DiarioClasse join fn in db.Faltas on new {…
-
0
votes1
answer74
viewsDoubt on how to set the type to return a list
I need to return some lists to my view. I am using Viewdata. But there is a problem, when declaring the variable, I do not know what type to put. I did it in the form below and is giving the…
-
0
votes1
answer61
viewsList string in 2 MVC tables
I have 3 models: Pessoa, Catequizando and Inscricao. I intend to make a query that returns the name of the person where CatequizandoID = PessoaID that will appear in a dropdown view CriarInscricao I…
-
0
votes1
answer37
viewsI do not know the feasibility of doing in lambda or Linq my expression
I have these two lists: List<string> dirZipDireto = ConfigurationManager.AppSettings["Dir_Zip_Direto"].Split(';').ToList(); List<string> arquivos = Directory.GetFiles(caminhoCommiter,…
-
0
votes1
answer66
viewsLinq does not return data. There is data in the table and I return by query
I tried to make a LINQ very similar to my query. This is my query. select * from PDV where tipo_PDV = 'R' and UF = 'DF' and Cidade = 'BRASILIA-DF' This is my LINQ var resultado_rede_descricao =…
-
0
votes1
answer114
viewsFormat query to send to Viewbag
I did a query in Latin, but the result was not as expected, it seems simple the problem but I can not solve. Result on the label: { Year = 2016/2017 } Expected result on label: 2016/2017 Controller:…
-
0
votes1
answer233
viewsSelect in Entity Framework is not working
I am performing a consultation using LINQ, very simple query I am using the following method. public void verificaAcesso( string usuario, string senha) { using (DbBancoContext banco = new…
-
0
votes1
answer224
viewsJOIN by LINQ in C#
I need to make a Join by LINQ in two lists using codeList. List 1 must exist in the second list (list 2) and must be returned. How do I do that? Obs.: I never Join via LINQ in c#
-
0
votes2
answers531
viewshow to call stored Procedure with Linq
Good morning, everyone. I have a stored procedure in the sql server, and I would like to call you on my application c#, via linq. Since now I appreciate any help…