A simple where clause is failing bringing back <>h__TransparentIdentifier...
from ts in TimeSpentQuery
.Where(z => z.JobId.HasValue ? z.JobId.Value != 0 ?
z.JobId.Value==j.JobId : false : false)
The list is created here
var TimeSpentQuery = (from js in context.TblTechnicianRecords.ToList()
group js by js.JobId into g
select new { JobId = g.Key, TimeSpent = g.Sum(x => x.EndTime.HasValue ? x.EndTime.Value.Ticks - x.StartTime.Ticks : 0) }).DefaultIfEmpty();
The error states InvalidOperationException: The LINQ expression '<>h__TransparentIdentifier7 => __TimeSpentQuery_0 .Where(z => z.JobId.HasValue ? z.JobId.Value != 0 ? z.JobId.Value == - then list a pile TransparentIdentifier-<>h__TransparentIdentifier0.j.JobId : False : False)'
for a simple where clause this has caused me all sorts of grief. What am I missing?
CodePudding user response:
It seems that dot net core, Entity Framework (EF) and C# has an issue with multiple LINQ from calls in building up a complex query(legacy data). I eventually created the data via multiple lists with simple joins. All previous from statements appear as <>h__TransparentIdentifier and when dealing with EF seemed to behave. but given a local list the system threw the above error, which is understandable as the SQL compiler has no Knowledge of the List, I hoped that the LINQ would compile as a group of statements rather than trying to form a single query.