Lazy load for nonnavigation property in EF 4.1

时光毁灭记忆、已成空白 提交于 2019-12-01 21:19:15
Ladislav Mrnka

No EF doesn't provide lazy loading for scalar and complex properties. The trick is to use table splitting where data from single table are mapped into two entities related with one-to-one relation. One entity is the principal and it contains navigation property to the dependent and because of that you can use lazy loading. Here is the question with link how to do it in EDMX and the answer provides solution for mapping in code-first (comments contains link to another example in MSDN forum).

I can't think of any situation where you'd desire a lazy loaded column in a table and couldn't justify putting it in its own table and mapping a separate entity to represent it. If you want a column lazy loaded, its probably a good indication that you need to create a separate entity. If you are mapping EF to a legacy database, then ignore everything I just said.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!