dotnetcore / EntityFrameworkCore.KingbaseES

Entity Framework Core provider for KingbaseES Database
PostgreSQL License
45 stars 6 forks source link

以下错误是我在 DotNetCore.EntityFrameworkCore.KingbaseES Version="6.0.22" 查询时报的错误 该如何解决 #12

Open XxyGitHub opened 5 months ago

XxyGitHub commented 5 months ago

The LINQ expression 'DbSet() .GroupJoin( inner: DbSet() .Where(v => v.EndDate < __now_0 || v.EndDate == null && (int?)v.OrgAuditState == (int?)已通过), outerKeySelector: user => (Guid?)user.Id, innerKeySelector: record => record.TraineeId, resultSelector: (user, recordsMap) => new UserRecordDto{ Id = user.Id, CreatedOn = user.CreatedOn, Unionid = user.Unionid, OpenId = user.OpenId, Name = user.Name, Sex = user.Sex, Nation = user.Nation, Political = user.Political, Phone = user.Phone, DeptId = user.DeptId, DeptCode = user.DeptCode, PostRank = user.PostRank, UnManageRank = user.UnManageRank, Birthday = user.Birthday, WorkUnit = user.WorkUnit, Job = user.Job, Days = recordsMap .AsQueryable() .Sum(v => v.Days), DeductDays = recordsMap .AsQueryable() .Sum(v => v.DeductDays), ActualDays = recordsMap .AsQueryable() .Sum(v => v.ActualDays) } )' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.

wangpengxpy commented 5 months ago

太复杂了翻译不了,你拆开查询,然后在内存中筛选过滤

XxyGitHub commented 5 months ago

var data = (from d in db.Set() join u in db.Set() on d.Id equals u.DeptId into usersMap select new { Deptname = d.Name, count = usersMap.Count(), d.Code }).ToArray();

          就是这种简单的into 不支持
XxyGitHub commented 5 months ago

image

XxyGitHub commented 5 months ago

就是一对多 into 看能否把驱动简单升级改下

wangpengxpy commented 4 months ago

上述这种简单的理论上应该支持的吧,报什么异常了,我抽空也测试下看看