I have implemented lazy loading in my program. it's done through a proxy class like:
class Order
{
public virtual IList<Item> Items {get; set;}
}
class OrderProxy
{
public override IList<Item> Items
{
get
{
if (base.Items == null)
Items = GetItems(base.OrderID);
return base.Items;
}
set { base.Items = value; }
}
}
The problem is that whenever I instantiate proxy class, without even touching the Items property, it tries to load Items!
As you may know, I want to instantiate proxy class and return the instance to BLL instead of domain object itself.
What's the problem?
Does .NET CLR access(read) properties in a class, when it's instatiating the class?
Any other methods?
Thanks