public class Product : EntityBase<int>, IAggregateRoot, IProductAttribute { public string Name { get; set; } public decimal Price { get; set; } public int SalesAmount { get; set; } public string Introduction { get; set; } public Brand Brand { get; set; } public Category Category { get; set; } protected override void Validate() { throw new NotImplementedException(); } public override string ToString() { return this.Name; } }查询生成Product实体时 属性Category是为null的,在数据库中Category和Product是一对多关系,请问怎么样才能自动生成Category。
public virtual Category Category{set;get;} public virtual int? CategoryId{set;get;}
查询时需要.Include(p=>p.Category)