Syndicate

News

My name's Marco De Sanctis and I'm an IT professional from Italy. This is my technical blog, about .NET and related application development and design technologies.

Download my Resume (.doc)

Recent Comments

10/23/2008 at 3:48 PM

sorry, my previous post was not complete... I trie...
by glondi

Read more...

9/22/2008 at 10:03 AM

Good one!!!Could you please post source code for t...
by Nisa

Read more...

9/10/2008 at 5:53 PM

I didn't even realize people were aware of the WPF...
by Mike Brown

Read more...

9/8/2008 at 1:22 AM

Marco,How are you handling scenarios where you nee...
by ctodd

Read more...

9/3/2008 at 1:00 AM

@ctodd: Hi,basically for the reasons I described a...
by Marco De Sanctis

Read more...

Recent Posts

Crunch mode is a pure waste of time, energy and money

7/31/2008 at 5:41 PM

Read more...

Double Click on the .sln file doesn't open Visual Studio on Vista

7/27/2008 at 9:02 AM

Read more...

Domain Model & Aggregates: when do master-detail associations happen?

7/22/2008 at 4:08 PM

Read more...

How I Got Started in Software Development

7/14/2008 at 12:16 AM

Read more...

Unleash the power of VisualStateManager with custom states

6/30/2008 at 12:12 AM

Read more...

When Lazy Loading associations is useful

posted on Thursday, May 22, 2008 12:28 PM | Filed Under [ LINQ Software Architecture ]

I was going to reply to a feedback to my last post, but from how much I was writing I realized it could deserve a post on its own.

When we decide to adopt the Domain Model pattern to represent data, we're going to deal with complex object graphs: it means that instead of SomeRelatedEntityId properties, we will have concrete references to related entities, a property of SomeRelatedEntity type in this case

Obviously, when you start a business transaction and you know from the beginning that the property X will be accessed, it could be (not always, read below!) a wise choice to eager fetch it to avoid too many DB round trips. However, I consider LazyLoad very useful in at least two practical cases:

  • n-level Master-Details: for example, a form with a header to edit the master entity, a grid below for its details and a button for each row which opens an AJAX modal popup to edit the detail's details. Without LazyLoad you should execute a huge query on the beginning (or many smaller ones) to fetch everything, and perhaps the user only wants to modify a Master's field. Oh... and what if the 2nd level details have many-to-one associations towards other entities? How big should our join be?
  • There are good chances that the related entity is still in the identity map: let's think about a list of entities with many-to-one association towards the same entity, for example a list of bills of the same customer. Without lazy load, you would fetch the same data many times, with lazy load and identity map, you will have no joins, only one query towards the Customers table, then the same entity will be used for every Bill.

Comments

Gravatar
# re: When Lazy Loading associations is useful
Posted by alkampfer on 5/30/2008 9:55 AM
In fact one of the greatest missing of entity framework is lazy loading. With domain model fetch strategies are really important, and the programmer sould have a wide range of choice, and lazy load probably will fits well most of the time.

alk.
Gravatar
# Ephedra dangers.
Posted by Lipodrene with ephedra. on 7/8/2009 11:02 PM
Connecticut ephedra lawyers. Ephedra products. Ephedra dangers. Atlanta ephedra attorneys. Ephedra.
Gravatar
# Generic xanax 2 mg no prescription.
Posted by Xanax withdrawal symptoms. on 7/12/2009 12:25 AM
Can you buy xanax without a prescription. Xanax. Titel auteur datum xanax medication bmnwbbuk.
Gravatar
# Ambien next day delivery canada.
Posted by Generic ambien. on 7/15/2009 9:08 AM
Generic ambien. Ambien side effects. Ambien cr. Ambien hallucinations dizziness. Ambien online no prescription overnight delivery. Ambien. Internet-rx.com ambien. Ambien prescriptions.
Gravatar
# How much is meridia in canada.
Posted by Meridia. on 7/15/2009 4:11 PM
Meridia over the counter.
Gravatar
# Ambien without a prescription.
Posted by Ambien. on 7/16/2009 4:17 AM
Wellbutrin together with ambien suicide. Ambien. Ambien online. Ambien side effects. Ambien lethal. Buy ambien 10.
Gravatar
# Combined cialis viagra.
Posted by Viagra vs cialis. on 7/18/2009 6:31 AM
Cheapest cialis. Cialis.
Gravatar
# Free animal sex videos.
Posted by Animal sex. on 7/18/2009 4:36 PM
Animal sex pics. Sex animal.
Gravatar
# Phentermine.
Posted by Phentermine hcl. on 7/19/2009 1:15 AM
No prescription phentermine. Phentermine without prescription. Adipex phentermine vs. Phentermine. Phentermine capsule. Phentermine online purchase. Buy phentermine diet pill.
Gravatar
# Generic percocet.
Posted by Percocet. on 7/20/2009 1:32 AM
Does percocet work. Percocet.
Gravatar
# Percocet.
Posted by Percocet. on 7/22/2009 12:46 AM
Percocet 93-490. Gereric names for percocet 5 325. Bioavailability of percocet. Percocet dosages.
Gravatar
# Vicodin detox.
Posted by Snorting vicodin. on 7/24/2009 1:11 AM
Purchase vicodin. Vicodin. Liquid form of vicodin. Dangers of vicodin. Vicodin drug information.
Gravatar
# Generic ambien.
Posted by Ambien cr addiction. on 7/29/2009 12:07 AM
Buy ambien without a prescription. Ambien latest side effects. Ambien. Generic ambien. Buy ambien online.
Gravatar
# Percocet.
Posted by Percocet shipped cod no prior. on 7/30/2009 12:17 AM
Effects of long term percocet use. Percocet. Percocet 93-490 10 mg.
Gravatar
# Diabetes one and soma.
Posted by Drug soma. on 7/31/2009 12:06 AM
Soma next day delievery. Soma. Soma cube.
Gravatar
# revolution response december
Posted by revolution response december on 8/4/2009 4:32 AM
total country web tar growth fossil
Gravatar
# 180 states stance
Posted by 180 states stance on 8/11/2009 10:30 AM
until australia next albedo ratified impact
Comments have been closed on this topic.