dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.77k stars 3.18k forks source link

Improve exception for client-server join #21914

Open ronaldkipngetich8923 opened 4 years ago

ronaldkipngetich8923 commented 4 years ago

Processing of the LINQ expression 'DbSet .Join( outer: __p_0, inner: domainUser => domainUser.DomainAccessID, outerKeySelector: domain => domain.ID, innerKeySelector: (domainUser, domain) => new { domainUser = domainUser, domain = domain })' 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.

ronaldkipngetich8923 commented 4 years ago

This is the code:

                var userDomains = await GetUserDomainsAsync(adminId);

                var users = await (from domainUser in _context.DomainUsers
                                   join domain in userDomains on domainUser.DomainAccessID equals domain.ID

                                   join user in _context.TvaUsers on domainUser.TvaUserID equals user.ID
                                   select new DomainUserViewModel
                                   {
                                       DomainModel = domain,
                                       TvaUserModel = _mapper.Map<TvaUserModel>(user)
                                   }).ToListAsync();

                return users;
smitpatel commented 4 years ago

Joining with client side collection cannot be translated to server.

roji commented 4 years ago

Better exception message?

ajcvickers commented 4 years ago

Backlog for better exception message.