Define which relational objects to load or not

Nov 23, 2009 at 1:21 PM


Is there an option to define which objects that have to be loaded from the database and which to be left blank.

In a complex database design where +3000 tables exists on which a bunch of relations exists the auto-loading isn't really that welcome and would be a blast to be able to define which tables/objects to load or not.


Michiel Alders

Dec 22, 2009 at 4:28 PM

The closest thing I can think of is setting the AutomaticallyLoadRelatedObjects = false on your ObjectContext, then load up the relations manually for each relation. Something like this

ObjectContext _context = ObjectContextFactory.ObjectContext;
_context.AutomaticallyLoadRelatedObjects = false;
ComplexRelationalObject myObject = ObjectContextFactory.ObjectContext.GetObject<ComplexRelationalObject>( "Id={0}", 3 );

myObject.SomeRelation = _context.GetObject<SomeRelation>( "Id={0}", myObject.SomeRelationId );