为什么在使用Includes的情况下, SqlFunc.Subqueryable查询不了数据 返回
SqlSugar
沟通中
2
1144
glen 发布于1个月前
悬赏:0 飞吻
var products = sugarQueryable.Includes(x => x.MediaFiles, y => y.MediaFolder).Select(x => new Product { Id = x.Id.SelectAll(), UrlAlias = SqlFunc.Subqueryable<UrlRecord>().Where(y => y.EntityName == entityName && y.EntityId == x.Id && y.IsActive).Select(y => y.Slug), //ProductImage = SqlFunc.Subqueryable<ProductMediaFile>().Where(y => y.ProductId == x.Id && y.IsDefault && y.Flag == 0 && !y.IsDelete).First(), //.Select(y => SqlFunc.MergeString(y.Domain, y.FilePath)), VendorName = SqlFunc.Subqueryable<Vendor>().Where(y => y.Id == x.VendorId).Select(y => y.Name), Category = SqlFunc.Subqueryable<ProductCategory>().Where(y => y.ProductId == x.Id).ToList(y => y.CategoryId), Material = SqlFunc.Subqueryable<ProductMaterial>().Where(y => y.ProductId == x.Id).ToList(y => y.MaterialId), ImprintMethod = SqlFunc.Subqueryable<ProductImprintMethod>().Where(y => y.ProductId == x.Id).ToList(y => y.ImprintMethodId), Color = SqlFunc.Subqueryable<ProductColor>().Where(y => y.ProductId == x.Id).ToList(y => y.ColorId), MediaFiles = x.MediaFiles, });
上面的代码在不使用Includes时, SqlFunc.Subqueryable是可以查询出数据
不知道有没有朋友碰到一样的问题,谢谢
热忱回答(2)
-
fate sta VIP01个月前
不能有
Id = x.Id.SelectAll(),
看一下导航DTO用法
0 回复 -
目 VIP01周前
@fate sta:
我这样写
SqlFunc.Subqueryable
也取不到数据
0 回复