开发者

Entity Framework, Business Objects, and Foreign Keys

开发者 https://www.devze.com 2023-03-16 10:51 出处:网络
I am new to EF and having a hard time understanding how the presentation layer can use information from multiple business objects (each BO represents an entity).I need a DataView to display data from

I am new to EF and having a hard time understanding how the presentation layer can use information from multiple business objects (each BO represents an entity). I need a DataView to display data from Order Details (products ordered) but the description column is really from Products. How does the binding work to have the DataView display columns from two different entities? Without using EF, the开发者_StackOverflow Order Details business object would have a call to SQL Server to return a DataTable that was created by using a T-SQL JOIN between the two tables. I don't know how to accomplish the same results using EF.


If presentation layer must use information from multiple objects you can either bind to navigation properties - for example you will load both order detail and product and you will navigate to product's description through navigation property on the detail. The other way (common in MVC) is creating new specialized view model type. This type will contain only information you need to show in the view and controller will transform order details and products to list of these custom classes.

0

精彩评论

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

关注公众号