0
我有3代表这是关系到每个人:加载相关实体
Product
有许多SuggestedPrices
Product
有许多ProductPricing
,所以我想撷取建议的价格,像这样:
await ctx.SuggestedPrices
.OrderByDescending(pp => pp.SuggestionDate)
.Include(p1 => p1.Customer)
.Include(p2 => p2.Product)
.Include(p3 => p3.Product.ProductPricing)
.ToListAsync()
根据您的要求:我添加了如下:
产品类:
public class Product : ReportingBase {
// Product-ProductPricing -> One Product has many Prices
public virtual ICollection<ProductPricing> ProductPricing { get; set; }
// Product-SuggestedPrices
public virtual ICollection<SuggestedPrice> SuggestedPrices { get; set; }
}
ProductPricing类:
public class ProductPricing {
// ProductPricings-Product
public virtual Product Product { get; set; }
public int ProductId { get; set; }
}
SuggestedPrice类:
public class SuggestedPrice : EntityBase {
// SuggestedPrices-Product
public virtual Product Product { get; set; }
public int ProductId { get; set; }
// SuggestedPrices-Customer
public virtual ApplicationUser Customer { get; set; }
public string CustomerId { get; set; }
}
但是当我添加一行.Include(p3 => p3.Product.ProductPricing)
我得到一个错误其中说:
使用圆点的路径和集合导航属性
选择操作我如何摆脱这种错误的?
感谢你的答案
不,这不是我的情况,我不能把'在'Product' @FedericoDipuma – Hooman
这样的实体上选择''操作符,将'SuggestedPrice'类添加到问题中,因此我们拥有查询的所有元素。 –
在这里你是@FedericoDipuma – Hooman