Problem with lazy loading implementation
- by Mehran
Hi,
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