开发者

EF4 POCO Many To One

开发者 https://www.devze.com 2023-02-07 19:17 出处:网络
I\'m trying to have开发者_高级运维 one POCO objects containing 2 tables. I have 2 tables : -Customer (#CustomerId, Name, CustomerProperties)

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

精彩评论

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