1
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
group by IDEstado
Code=
var dbApp = new App();
var dbNucleo = new Nucleo();
var estados = (from e in dbNucleo.Estado
select new { e.ID, e.Nome }).ToArray();
var result = (from w in db.PessoaEstado
join e in estados on w.IDEstado equals e.ID
where w.IDPessoaMaster == IDPessoaMaster
group new { w, e } by new
{
e.Nome
} into z
select new
{
nome = z.Key.Nome;
qtd = z.Count()
}).OrderByDescending(x => x.qtd);
return result.ToList<dynamic>();
returns the error:
Could not create a constant value of type 'Anonymous Type'. Only primitive types or enumeration types are supported in this context.
Which line error occurs?
– Leonel Sanches da Silva