Login Skip Navigation LinksWilsonORMapper > Forums Search
Demo Version Demo Version
Download and try for yourself a fully working demo version, including sample apps and documentation.  The only limitation is that the demo version only works inside the debugger.

PayPal Subscribe
Get It All for $50 USD:
WebPortal, ORMapper,
Source Code, All Updates
PayPal

User Login User Login
Log In
 
 
Reset Password

Wilson ORMapper Forums Wilson ORMapper Forums : Feature Requests : Lazy load controlled

Date Post
3/31/2006 12:16:33 PM

Hi Paul,

I have one relation Order->OrderDetails with lazyLoad=false

If I do : ObjectSpace.Save(..) I need to inform the "persistDepth",  but isn't possible to do it :

ObjectSpace.GetObject(typeof(Order),PersistDepth.SingleObject)

Why I need it ?

Sometime I need all object graph, sometime not. It's very good for distributed application, because I need to controller the 'LazyLoad' for performance issue.

Thanks,
Alexnaldo Santos

3/31/2006 12:22:44 PM Hi Alexnaldo:

That of course isn't a problem with the default lazyLoad="true" case, but you are correct that when you disable lazy-loading then you lose that flexibility.  This is one reason that distributed apps are much harder to design correctly -- its not necessarily a coding challenge as much as it is a design challenge.  You either need to decide what you want and go with it at all times, or you need to create two different types that differ only in their relationships (not typically recommended, but listed here since it is an alternative).  My advice is that if you almost always want the relationships then you just accept that you will always get them, or you go without them and get them with your own code only when needed.  Which is best?  That very much depends on your application and its usage scenarios -- thus the design challenge of distributed apps.

Thanks, Paul Wilson
3/31/2006 10:20:57 PM

I understand you, but here's a good pattern that solve this problems :

public class Person
{
Guid m_PersonId;
String m_FirstName;
SaleOrderCollection m_SaleOrder;

public Guid PersonId {get{ return m_PersonId;} set {m_PersonId=value;}}
public String FirstName { get { return m_FirstName; } set { m_FirstName = value; } }
public SaleOrderCollection SaleOrder { get { return m_SaleOrder; } set { m_SaleOrder = value; } }

}

public interface IPersonFactory
{
void Load(Person objInfo, int nDepth);
void Insert(Person objInfo, int nDepth);
void Update(Person objInfo, int nDepth);
void Delete(Person objInfo, int nDepth);
void Save(PersonCollection objList, int nDepth);
void DeleteColl(PersonCollection objList, int nDepth);
}

I will try to create a 'Template' to generate the correct implementation of this.