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。
Ps:数据库是我自己手动创建的,然后用code first匹配的
2 回答
森林海
TA贡献2011条经验 获得超2个赞
public virtual Category Category{set;get;} public virtual int? CategoryId{set;get;}
- 2 回答
- 0 关注
- 464 浏览
添加回答
举报
0/150
提交
取消