I'm getting this error with trying to execute my query.
System.InvalidOperationException: .Where(ti => (int)ti.Inner.OptionType == 1 && ti.Inner.QualifierId == null && ti.Inner.CreditingMethod != "xxx" && __ToList_0 .Any(e => e.Vdate== (Nullable)ti.Outer.ADate))' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.'
The object that I'm populating is
public class OCList
{
public DateTime? Vdate{ get; set; }
public Double? VWeight{ get; set; }
}
/// example of adding to the list
List<OCList> ocList= new List<OCList>();
if (request.Date1 != null && request.Weight1 != null)
{
ocList.Add(new OCList{ Vdate = request.Date1.Value, VWeight = request.Weight1.Value });
}
it error's here:
&& ocList.ToList().Any(e => e.Vdate == x.Tb2.ADate))
Linq expression:
var results = _context.Tb1
.Join(_context.Tb2, oc => oc.OptionId, o => o.OptionId, (oc, o) => new { OptionCost = oc, Option = o })
.Where(x => x.Tb2.Val1 == 1
&& x.Tb2.Val2 == null
&& ocList.ToList().Any(e => e.Vdate == x.Tb2.ADate))
////.........