Lazy load for nonnavigation property in EF 4.1

2019-02-25 01:52发布

Is there a simple solution to make lazy load for nonnavigation property in the EF 4.1? For example, for byte array.

2条回答
女痞
2楼-- · 2019-02-25 02:42

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.

查看更多
在下西门庆
3楼-- · 2019-02-25 02:50

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).

查看更多
登录 后发表回答