开发者

Entity Framework: Creating single entity from related, cascading tables

I am working with a database contains related tables for storing person address details. The following tables store the information – County, City Suburb, Address and Address Type.

The Address table holds street and house number information in addition to AddressTypeId (Associated to AddressT开发者_开发知识库ype Table). The Address table also has a SuburbId column for the association with the Suburb table. The associations of a person’s address cascade down to the County table

Entity Framework: Creating single entity from related, cascading tables

.

I want the Person data object to have an IList property. What would be my best approach to achieve this?

  1. Use a stored procedure to generate the Address entity on the Entity designer.
  2. Create a complex type and add this to the Person type as IList.

There might be some other recommended way than the above options. If there is a step-by-step example some one could point me to, that would be great.


As far your question you can write a stored procedure that gets all the address information. Have a select statement at the end of your stored procedure selecting all of the address information.

When you add this procedure entity framework(4.0 I assume)...you can create a function import and ef4 will create an complex type for return of your stored procedure. Here is a tutorial.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜