I get a list that contains the level of access to a request and I want to get a list of requests that have this level.
when returning "return vrequest.AsEnumerable (). ToList ();" I get this error You can not create a constant value of type 'SistemaControlGastos.ModeloBD.CatNivel'. Only primitive types or enumeration types are supported in this context.
then in the part of where it would have to change to make the condition that meets the list of levels
public List<object> getRequestGerent()
{
List<CatNivel> listNivel = Authweb.listNivel.Where(x => x.tipo == "primary").ToList();
var vrequest = (from trequest in Context.Request
where listNivel.Any(cn => cn.nivel == trequest.position)
select new
{
idRequest = trequest.IdRequest,
requestDate = trequest.nRequesition.requestDate,
cantidad = (from tpd in Context.Product
where tpd.FKReq == trequest.IdRequest
select tpd.totalMount).ToList().Sum(),
status = trequest.nRequesition.status,
nivel = trequest.position,
cCot = (from tc in Context.Cotizacion
where tc.FKRequest == trequest.IdRequest
select tc).Count(),
categoria = trequest.nRequesition.categoria
});
return vrequest.AsEnumerable<object>().ToList();
}
example
in this is what I want to do but in a single consultation
var rProvidier = Context.regProvider
.Where(x => x.FKRequest.Equals(vrequest.IdRequest))
.ToList();
List<CatProvider> lcp = new List<CatProvider>();
for (int i = 0; i < rProvidier.Count; i++)
{
lcp.Add(getProvider(rProvidier[i].FKCatProvider));
}
public CatProvider getProvider(int idp)
{
var cp = (from tp in Context.CatProvider
where tp.IdProvider == idp
select tp).FirstOrDefault();
return cp;
}