【发布时间】:2014-12-06 04:44:28
【问题描述】:
我目前正在使用 OData V4 并希望加入 2 个表 Account 和 Product:
表格如下: 帐户:ID、姓名、地址、颜色代码,
产品:Id、AccountId
Product表中的AccountId是映射到Account表中Id字段的外键
在我的构建器中,我有:
var ProductType= builder.EntityType<Product>();
当我构建 Product 实体时,我希望从 Account 实体中获取“ColorCode”值。
如何在模型构建器中建立这种关系?
我希望产品类看起来像这样:
public class Product
{
public string Id { get; set; }
public string AccountId { get; set; }
public string ColorCode { get; set; }
}
【问题讨论】: