Questions tagged as 'linq'

2
answers

How to generate OR comparisons dynamically with LINQ?

I have a query where I should get certain values by comparing if a column is equal to a X value. X is an array that can have 1 to 4 values. How can I in my query with LINQ dynamically mount these OR ? Belo...
asked by 05.04.2017 / 17:03
1
answer

Check if multiple columns contain a value?

Query: query = query.Where(t => t.campo1.Contains(filter) || t.campo2.Contains(filter) || ......); I would like to know if there is a way that I do not need to keep all fields in the table, do something more general to se...
asked by 27.09.2017 / 14:13
2
answers

Find specific value within a .txt file C #

I have a .txt file with the following lines: 000-000 = CRT 001-000 = 00000021 009-000 = 00 012-000 = 247823 013-000 = 0000559877 022-000 = 24082017 023-000 = 152842 032-000 = 80F1 100-000 = JORGE EXPEDITO 307-000 = S17SNSNNNSPSS9MSNN00 3...
asked by 25.08.2017 / 14:01
1
answer

Linq groups and fetches the max id

Is there any way to optimize the code below so that you search for the forms that are at the maximum version according to IdCentroCusto ? In the code below I'm doing the grouping and getting the CM.Max(d => d.Versao) to fetch...
asked by 07.12.2015 / 18:52
2
answers

How to do the where ands of where dynamically with linq and Entity Framework?

How can I make ands dynamically in where using Linq and entityFramework? Thank you in advance for any help. return _dbContext.TbParceiro //Preciso fazer algo do tipo mas isso não funciona, não sei como posso fa...
asked by 12.12.2017 / 18:33
3
answers

Pass List as expression parameter LINQ

I have a LINQ expression where the result is saved in the query variable, which is transformed into a list, this query returns a series of "RA" attributes. p> I would like to pass this list of attributes as a parameter in the LINQ expressi...
asked by 04.11.2015 / 03:26
1
answer

Error when passing AddDays on Lambda expression

In this lambda, it gives me the error below, when it enters the IF: var resultado = webDB.T_ControleColetor .Where(cn => cn.CNPJ == cnpj) .Where(dt => dt.DataControle == DateTime.No...
asked by 06.05.2014 / 02:13
1
answer

How to perform a Count in several columns?

I would like to make a COUNT using LINQ / LAMBDA, but I'm having difficulties. Can you help me? The idea is to reproduce the following query: SELECT Conta, Tipo, Documento, Nome, COUNT(0) AS Qtde FROM TaxaPrecificacao GROUP BY Conta...
asked by 27.09.2017 / 17:41
1
answer

How to simplify a foreach by a Linq - Lambda expression

Performance is not a problem in my project, I want to know a simpler and readable replacement for my foreach using Linq and Lambda (if possible). // 'DiscoVirtual' é uma classe // 'this.HDs' é um 'List<DiscoVirtual>' // 'Atual' e 'Novo'...
asked by 23.08.2015 / 19:27
1
answer

How to join with more than two lists?

I have three classes: class Cbo { public string ProfId { get; set; } public string Cbo { get; set; } public string Descricao { get; set; } } class Profissional { public string ProfId { get; set; } public string NomeProf {...
asked by 29.01.2017 / 19:26