我首先使用实体框架代码,我有两个实体:
public class Product
{
public int ProductID { get; set; }
public decimal Price { get; set; }
public int ProductCategoryID { get; set; }
public virtual ProductCategory ProductCategory { get; set; }
[NotMapped]
public int Quantity { get; set; }
}
public class ProductStorage
{
[Key]
public int ProductId { get; set; }
[ForeignKey("ProductId")]
public virtual Product Product { get; set; }
public int Quantity { get; set; }
}
我似乎无法获得Product
充满该Quantity
属性的列表。
我试过
from pr in repository.Query<Product>()
join st in repository.Query<ProductStorage>() on pr.ProductID equals st.Quantity
select new Product()
{
ProductID = pr.ProductID,
....
Quantity = st.Quantity
};
但这没有用。