开发者

Combine data from multiple tables into one View Model

I'm using ASP.NET MVC2 with EF4 connected to a SQL Express db.

Situation: Without getting into too much specifics, I have one table called 'Plan.' Under 'Plan' are several different categories that are related to a single Plan item [say Category A, Category B, Category C and Category D]. Each 'Category X' table has a beginDate, endDate and other details specific to that category.

I'd like to be able to create a summary page that combines all items from Category A, Category B, Category C, and Category D and sorts by beginDate - but only need a few of the columns [eg - begin/end date, name, id].

Any suggesti开发者_开发问答ons on where to begin?

Thank you.


I'm not sure if its the best option, but when I need to do something similar, I create a ViewModel for the data I want and I use AutoMapper to remap the Domain objects to the ViewModel. Again, not sure that is the best option, but it works for me.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜