Print Page | Close Window

EntityReferenceLoadStrategy

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1637
Printed Date: 25-Mar-2025 at 10:42am


Topic: EntityReferenceLoadStrategy
Posted By: bfoster
Subject: EntityReferenceLoadStrategy
Date Posted: 04-Feb-2010 at 11:37am

I am evaluating DevForce and do not like the idea of the "Getter" automatically loading navigation properties.  I would like to use EntityReferenceLoadStrategy.DoNotLoad and implement my own explicit lazy loading.  However it looks like I would need to change the FetchStrategy to CacheOnly which obviously would not be very usefull. 

Would the world exlpode if I set the load strategy directly (via reflection), or must I resort to code gen?
 
Thanks!



Replies:
Posted By: GregD
Date Posted: 05-Feb-2010 at 2:26pm
There are two approaches you can use:

1)     
The EntityReferenceStrategy can be set for a property via the EntityRelationRole via the static EntityRelations defined for each type.  This effects all navigation on this property.
a.  EntityRelations.FK_OrderSummary_Customer.Role1.ReferenceStrategy = EntityReferenceStrategy.NoLoad;
b.  EntityRelations.FK_OrderSummary_Customer.Roles.First(er => er.EntityType ==
   typeof(Customer)).ReferenceStrategy = EntityReferenceStrategy.NoLoad;

2)      You can set the EntityManager.DefaultQueryStrategy = QueryStrategy.CacheOnly



Print Page | Close Window