You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a many-to-many relationship between User and Location, and I’m using EF Core to manage the bridging table between them.
I’ve been trying to create a DataLoader that uses the ISelectorBuilder to project locations as a paged result when querying users, with some help from Michael in the Slack channel.
However, when I run it with the selection commented out, it returns an empty collection. But when I uncomment it, I get an error due to the dynamic type.
[DataLoader]internalstaticValueTask<Dictionary<Guid,Page<Location>>>GetLocationsByUserIdAsync(IReadOnlyList<Guid>keys,PagingArgumentspaging,ISelectorBuilderselector,ApplicationDbContextdatabase,CancellationTokencancellation=default){return database
.Users
.AsNoTracking().Where(x => keys.Contains(x.Id)).SelectMany(x => x.Locations.Select(l =>new{ Id = l.Id, Location = l })).OrderBy(x => x.Location.Name)// uncommenting this will result is type errors// .Select(x => x.Id, x => x.Location, selector).ToBatchPageAsync(x => x.Id,x => x.Location, paging, cancellation);}
If you execute the following query using the reproduction repository you will encounter and be able to reproduce the issue:
I'm looking for a way to use the new ISelectorBuilder with many-to-many relationships without having to manually introduce bridging tables, leaving that responsibility to EF Core instead.
What is actually happening?
If you're not using the ISelectorBuilder, you'll get an empty result. Trying to use the .Select function will cause the issue below due to the required dynamic type.
Relevant log output
The type arguments for method 'IQueryable<KeyValueResult<TKey,IEnumerable<TValue>>> GreenDonut.Selectors.SelectionDataLoaderExtensions.Select<T,TKey,TValue>(this IQueryable<T>, Expression<Func<T,TKey?>>, Expression<Func<T,IEnumerable<TValue>>>, ISelectorBuilder)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Additional context
No response
The text was updated successfully, but these errors were encountered:
Product
Hot Chocolate
Version
14.0.0
Link to minimal reproduction
https://github.com/PHILLIPS71/hc-7615
Steps to reproduce
I have a many-to-many relationship between User and Location, and I’m using EF Core to manage the bridging table between them.
I’ve been trying to create a DataLoader that uses the
ISelectorBuilder
to project locations as a paged result when querying users, with some help from Michael in the Slack channel.However, when I run it with the selection commented out, it returns an empty collection. But when I uncomment it, I get an error due to the dynamic type.
If you execute the following query using the reproduction repository you will encounter and be able to reproduce the issue:
What is expected?
I'm looking for a way to use the new
ISelectorBuilder
with many-to-many relationships without having to manually introduce bridging tables, leaving that responsibility to EF Core instead.What is actually happening?
If you're not using the
ISelectorBuilder
, you'll get an empty result. Trying to use the.Select
function will cause the issue below due to the required dynamic type.Relevant log output
The type arguments for method 'IQueryable<KeyValueResult<TKey,IEnumerable<TValue>>> GreenDonut.Selectors.SelectionDataLoaderExtensions.Select<T,TKey,TValue>(this IQueryable<T>, Expression<Func<T,TKey?>>, Expression<Func<T,IEnumerable<TValue>>>, ISelectorBuilder)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Additional context
No response
The text was updated successfully, but these errors were encountered: