The type arguments for method GroupJoin cannot be inferred from the usage
我对使用实体框架还很陌生,我一直在遇到我的代码无法编译的问题。我得到的错误消息是:
The type arguments for method
'System.Linq.Queryable.GroupJoin(System.Linq.IQueryable,
System.Collections.Generic.IEnumerable,
System.Linq.Expressions.Expression>,
System.Linq.Expressions.Expression>,
System.Linq.Expressions.Expression,TResult>>)'
cannot be inferred from the usage. Try specifying the type arguments
explicitly.
我做了一些搜索,发现了一些类似的问题,但没有什么能帮助我解决我的问题。我只是想输出一些简单的东西来进行调试,下面是我现在拥有的代码:
1 2 3 4 5 6 7 | var result = _context.Set<User>() .Where(user => user.GraphMeetingStatistics && user.Id == userId) .GroupJoin(_context.Set<Meeting>() .Where(meeting => meeting.UserId == userId), user => user.Id, meeting => meeting.Guid, (user, meeting) => meeting); |
对于这个错误,我很感谢你的帮助
根据托马斯·列夫斯基的说法,加入收藏的钥匙必须是同一类型的。因此,在你的案件中,
Dotnotperls has a good,basic overview of how EDOCX1&4).Works,and describes the arguments as such:
Arguments 1 and 2:
Argument one is the secondary collection. And
argument two is aFunc that returns the key from the first object
type.Arguments 3 and 4:
A
Func that returns the key from the second object
type, and one that stores the grouped object with the group itself.