Questions tagged as 'linq'

1
answer

Capture the query TraceSql in LINQ c #

I have a query in LINQ and I need to capture the generated sql, but I did not succeed. The conversion to ObjectQuery that I found does not work. What is missing? var sqlConsulta = (from a in Sessao.Query<RequisitorioNaoLevantado>()...
asked by 14.08.2017 / 22:01
1
answer

Error with lambda and float fields

Whenever I load my lambda, give me this error:    System.InvalidOperationException: 'The specified cast from a   materialized 'System.Double' type to the 'System.Single' type is not   valid. ' This only happens with float fields. If I comm...
asked by 23.08.2017 / 15:14
1
answer

Filter with Linq or Lambda using Join and Group By

Good Afternoon In a table where it is always inserted new records can occur to have the same Date and the same RateCode, however I want to get a list of this table but for each Date group, RateCode would like me to return the last record inse...
asked by 11.05.2017 / 19:48
1
answer

Working with anonymous type

I have the following code snippet: var filter = new { categoria = 1, cond2 = foo, ... }; p = new ProdutoBusiness().listarProdutos( filter ).ToList(); I wanted to work with this anonymous type as a parameter to filter, but I do not know how...
asked by 12.12.2016 / 21:07
1
answer

Total sum with linq

I have no idea how to get Total Value = 755.00 from this 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: 755.00 I im...
asked by 13.11.2016 / 22:49
1
answer

LINQ to SQL - Exception when giving sum () in a query that contains another subquery using LINQ

private decimal GetBankAccountCashierTotal() { var company = _context.Company.FirstOrDefault(); return _context.PersonBankAgencyAccount .Where(p => p.PersonID.Equals(company.PersonID)) .Wh...
asked by 01.12.2016 / 16:30
1
answer

How to join two different lists using LINQ and where?

I have three classes: class Cid { public string cid { get; set; } //importo esse campo via txt public string descricao { get; set; } //importo esse campo via txt } class Relacionamento { public string cid { get; set;...
asked by 19.01.2017 / 15:51
1
answer

Dynamic Linq Sorting using System.Linq.Dynamic

I'm trying to sort a list using the System.Linq.Dynamic library, it follows the snippet of code: list = db.TABELA.Where(consulta.Colum + ".Contains(@0) ", consulta.filtro).OrderBy("@0 ", "codigo").Take(10).ToList(); but the resu...
asked by 09.09.2016 / 22:02
1
answer

How to do select using LINQ with 2 tables? [closed]

Thisismyselect:bd=newAcessoBancoDados();bd.Conectar();stringcidade="SELECT c.Nome FROM Cidade c join Estado e on c.EstadoId = e.EstadoId WHERE e.Sigla = '" + dto.Estado + "'"; dt = bd.RetornDataTable(cidade); That in the register I selec...
asked by 20.08.2016 / 01:33
1
answer

Argument data type xml is invalid for argument 1 of len function

I'm mapping a property to the xml-type database using Migrations . public string Xml { get; set; } this.Property(t => t.Xml).HasColumnName("Xml").HasColumnType("xml"); However, querying the class using Linq returns the error. _...
asked by 23.02.2016 / 14:59