question

HANMINGONG-1538 avatar image
0 Votes"
HANMINGONG-1538 asked JackJJun-MSFT commented

EF Core SQL rewrite query error

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?


dotnet-entity-framework-core
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@HANMINGONG-1538,Could you provide a small completed code example to reproduce your problem? I can not analyze your problem without your full code.

0 Votes 0 ·

0 Answers