EF Core SQL rewrite query error

HAN MING ONG 21 Reputation points
2021-09-20T12:09:42.637+00:00

Hi, I am using Entity Core framework and I encounter the 'rewrite' with the following linq

var query = await _context.OnlinePayments.Include(x => x.OnlinePaymentDetail)
.FirstOrDefaultAsync(x => x.OnlinePaymentDetail!.InputSource!.Code == inputSource);

error message
The LINQ expression 'DbSet .LeftJoin( outer: DbSet, inner: o => EF.Property>(o, "Id"), outerKeySelector: o0 => EF.Property>(o0, "Id"), innerKeySelector: (o, i) => new TransparentIdentifier( Outer = o, Inner = i )) .Where(o => o.Inner.InputSource.Code == __inputSource_0)' 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.

Can someone please advise me how to rewrite and what went wrong?

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
710 questions
{count} votes