开发者

Entity Framework 4 POCO - Lazy + Eager Loading

开发者 https://www.devze.com 2023-01-08 19:51 出处:网络
I have the following DB structure (simplified version): Comments - CommentId, UserId Users - UserId UserDetails - UserId, Address, Phone, etc.

I have the following DB structure (simplified version):

Comments - CommentId, UserId
Users - UserId
UserDetails - UserId, Address, Phone, etc.

I am using EF 4 with PO开发者_如何学PythonCOs. The User property of the Comment class is marked as virtual (to enable lazy loading for it). However, I want when the User property is loaded (lazy) also its UserDetails property to be loaded (the relation Users - UserDetails is 1:1). Is that possible? Can I specify it in some way? I want to make lazy + eager loading in some way..


No, you can't do that. You can, however, turn multiple tables into a single entity using the entity splitting technique. Sounds like that's what you're really after.

0

精彩评论

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

关注公众号