5
I am trying to make a query in LINQ, and is returning the following error message:
Could not create a System.Object type constant value. Only primitive types or enumeration types are supported in this context
One structure is recursive, so one structure can be daughter of another.
When I get the idPai
, I want him to bring me only the children of that structure, and when I pass the id
, I want that specific structure, that idPai
.
Action would be like this:
Estrutura/{idPai}/{id}
The query is the following:
var list = (from e in ent.Estrutura
join t in ent.TipoEstrutura on e.idTipoEstrutura equals t.id
join ee in ent.Estrutura on e.idEstrutura equals ee.id into eleft
from ePai in eleft.DefaultIfEmpty()
where ((idPai.HasValue ? e.idEstrutura.Equals(id) : e.idEstrutura.Equals(null))
&& (id.HasValue ? e.id.Equals(id) : e.id != null))
select new SigProcessos.Entity.ViewModel.Estrutura
{
Id = e.id,
IdEstrutura = e.idEstrutura,
IdTipoEstrutura = t.id,
DescricaoEstrutura = e.descricao,
DescricaoEstruturaPai = (null != ePai ? ePai.descricao : default(string))
}).ToList();
return list;
I appreciate the help!
Your default(string) is what?
– Marco Souza
É Entity Framework?
– Leonel Sanches da Silva