我需要在GroupJoin之后执行计数。
var query = _context.Users.GroupJoin(_context.Customers, u => u.Id, c => c.UserId, (u, c) => u);
int count = query.Count();
当执行计数行时,我收到错误:
类型的表达式System.Collections.Generic.IEnumerable' 1 [System.Collections.Generic.IEnumerable' 1 [MyClass]]'不能用于返回类型' System.Collections.Generic.IEnumerable`1 [System.Int32]'
如果我使用常规Join(),一切正常。 使用Entity Core 1.0
有什么想法吗?
更新:StackTrace:
at System.Linq.Expressions.Expression.ValidateLambdaArgs(类型delegateType,Expression&amp; body,ReadOnlyCollection&#39; 1参数) 在System.Linq.Expressions.Expression.Lambda [TDelegate](表达式主体,字符串名称,布尔值tailCall,IEnumerable&#39; 1参数) 在System.Linq.Expressions.Expression.Lambda [TDelegate](表达式主体,布尔值tailCall,IEnumerable&#39; 1参数) 在System.Linq.Expressions.Expression.Lambda [TDelegate](表达式主体,ParameterExpression []参数) 在Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateExecutorLambdaTResults 在Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor [TResult](QueryModel queryModel) 在Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery [TResult](QueryModel queryModel) 在Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler。&lt;&gt; c__DisplayClass19_0&#39; 1.b__0() 在Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery [TResult](Object cacheKey,Func&#1; 1编译器) 在Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQuery [TResult](表达式查询) 在Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute [TResult](表达式查询) 在Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute [TResult](表达式表达式) 在System.Linq.Queryable.Count [TSource](IQueryable&#39; 1来源) 在MyProject.Services.User.UserService.SearchUsers(ContactSearchCriteriaDto cscd)中的C:\ Users \ john-luke.laue \ repositories \ MyProject \ src \ Services \ User \ UserService.cs:line 59 < / p>
第59行是行:int count = query.Count();