跨库导航使用问题
hmy4677 opened this issue · comments
1.跨库导航为什么不能用Select(),只能用Includes()啊?
return await DbScoped.Sugar.QueryableWithAttr<PatientApmtEntity>() //PatientApmtEntity是db1
.Select(p => new
{
p.Id,
p.DoctorId,
p.Doctor.Account //Doctor是db2
}).ToListAsync();
2.用两个一样的实体Leftjon()会报错
return await DbScoped.Sugar.QueryableWithAttr<ReturnVisitEntity>()
.LeftJoin<DoctorEntity>((p, o) => p.CreateDoctorId == o.Id).AS<DoctorEntity>("panda_base.base_user")
.LeftJoin<DoctorEntity>((p, o, i) => p.ReturnVisitDoctorId == i.Id).AS<DoctorEntity>("panda_base.base_user")
跨库导航支持功能有限,你可以ToList后面内存处理, 第二个问题我近期修复
DbScoped.Sugar.QueryableWithAttr()
.LeftJoin((p, o) => p.CreateDoctorId == o.Id).AS("panda_base.base_user")
.LeftJoin(db.Queryable("panda_base.base_user"),(p, o, i) => p.ReturnVisitDoctorId == i.Id)
相同实体这么用 突然想起来了
源码已经支持了 同服务器跨库 , 下载源码你可以进行测试没问题我会发布NUGET
await DbScoped.Sugar.QueryableWithAttr<PatientApmtEntity>() //PatientApmtEntity是db1
.Select(p => new
{
p.Id,
p.DoctorId,
p.Doctor.Account //Doctor是db2
}).ToListAsync();
其他用户已验证可以用了,如果还有疑问,发新的issue