开发者

EF4 POCO Many To One

I'm trying to have开发者_高级运维 one POCO objects containing 2 tables.

I have 2 tables :

-Customer (#CustomerId, Name, CustomerProperties)
-CustomerExtended (#ExtendedId, #CustomerId, extendedProperties)

And I would have one POCO object:

Customer

- CustomerId
- Name
- CustomerProperties
- ExtendedProperties

Have you any idea?


This is code-first solution (without fluent code).

public class Customer
{
  public int CustomerId { get; set;}
 //navigation
  public List<CustomerProperty> CustomerProperties { get; set;}
}

public class CustomerProperty
{
  public int CustomerPropertyId { get; set;}
  //navigation
  public Customer Customer { get; set; }
}

It will pruduce two tables CustomerProperties and Customers, and you can access CustomerProperties from the Customer instance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜