I'm trying to make a query
where I check if the week day is the chosen one to create a list of data that loads in a ViewModel.
Query:
var plan = db.Servicos.Where(s => (TecnicoResp.HasValue ? s.NumTransportado == TecnicoResp.Value : true)
&& ((IdFornecedor.HasValue ? s.FornecedorID == IdFornecedor : true) && (estabelecimentosDrop.HasValue ? s.EstabelecimentoID == estabelecimentosDrop : true))
&& (IdFornecedor.HasValue ? s.FornecedorID == IdFornecedor : true)
).SelectMany(sc => sc.Planeamento).Where(p => (checkQua == "Sim" ? p.DataAssistenciaProgramada.Value.DayOfWeek == DayOfWeek.Wednesday:true));
//O erro encontra-se no where a seguir ao SelectMany
List<FiltroSPlaneamentoViewModel> resultPlaneamento = FiltroSPlaneamentoViewModel.carregaListaSPlanPlanemaneto(plan.ToList());
So I see if the value passed checkQua
is "Sim"
, and if it is I'll get the dates where the day of the week is Wednesday. I think the error is from here, because when I send the data to the ViewModel resultPlaneamento
I get the following error:
The specified type member 'DayOfWeek' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.