Back to list
Views:   0
Replies:  0
Archived
,
Reply 1
Another example is when you need to access a parent object in your object graph. For example, if you have an Invoice and you want to know the Customer of this Invoice, it will be more easy to say :

Invoice.Customer.Name
so, in this case you should prepare you Invoice class to load the Customer Object in the getter property like :

private Customer _customer;

  
public Customer Customer
{
   get
   {
       if (_customer == null) 
       {
          _customer = GetCustomerById( Id );
       }
       return _customer;
   }
}
I hope this helps
 
Redha Reghioua, Apr 25, 2010
Reply 2
Thanks Shiva, Juan, Syed
Jebby Philip, Mar 24, 2010
Reply 3
Lazy loading is just a fancy name given to the process of intializing a class when it's actually needed. You might already be doing it.
For example suppose you are maintaining a collection of orders on the form and it's a class level variable, which you will fill thought out the life time of the form.

Since you know that you are going to use this collection you may say while declaring at form level

private List<orders> myOrders = new List<orders>();

or you may choose to lazy load it

private List<orders> myOrders;


and then in you form when you add the first item you do this

if ( myOrders == null)
     myOrders = new List<orders>();

myOrders.add (firstOrder);
Syed Saqib Ali Tipu, Mar 20, 2010
Reply 4
Yes, you can. Lazy loading is nothing but deferring the loading of constiuent objects (referenced objects) of a class until it is required/accessed. May be this would help: http://www.lhotka.net/Article.aspx?id=48548dc3-3b64-4bb3-bc84-9476b8f77600
Siva M, Mar 19, 2010
Good explanation
Mar 13, 2010
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas