Hi all,
Here's a funny one! This LINQ code works fine in LinqPad but when run in Asp Core EF it throws an exception, any ideas why?
var count = await _context.User.Where(x => _context.Members.Where(v => _context.Lock.Select(s => s.CustomerId).ToList().Contains(v.CustomerId)).Select(s => s.CustomerId).ToList().Contains(x.Id)).CountAsync();
Exception that I get is:
System.InvalidOperationException: Processing of the LINQ expression 'AsQueryable<int>(ToList<int>(Select<Members, int>(
source: Where<Members>(
source: DbSet<Members>,
predicate: (v) => ToList<int>(Select<Lock, int>(
source: DbSet<Lock>,
selector: (s) => s.CustomerId)).Contains(v.CustomerId)),
selector: (s) => s.CustomerId)))' by 'NavigationExpandingExpressionVisitor' failed. This may indicate either a bug or a limitation in EF Core. See https://go.microsoft.com/fwlink/?linkid=2101433 for more detailed information.