3

I have the following DB structure (simplified version):

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

I am using EF 4 with POCOs. 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..

Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
Boyan Mihaylovv
  • 338
  • 2
  • 10
  • So you're wanting to Lazy load a `User` data. But, when the `User` is lazy-loaded, you then want to make sure the `UserDetails` is also loaded at the same time? – Pure.Krome Jul 27 '10 at 07:36
  • I don't know how much you've simplified, but if the `User` and `UserDetails` tables are really 1:1 and not 1:0..1 or 0..1:0..1, you should be able to put the to tables together into one, and load everything lazy... – Tomas Aschan Jul 27 '10 at 07:37
  • @Pure.Krome - yes. @Tomas Lycken - well, my DB design is like this and I cannot change it (also I don't want to) – Boyan Mihaylovv Jul 27 '10 at 07:42

1 Answers1

1

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.

Craig Stuntz
  • 125,891
  • 12
  • 252
  • 273