Results 1 to 2 of 2

Thread: Object Factories with Lazy Loading in C#

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    12

    Object Factories with Lazy Loading in C#

    I'm looking for a lazy loading solution in c#.

    The idea is, to have a kind of object factory, which will be responsible for creating my entity objects.
    When a property of such an object is accesed and it is not yet loaded, the factory
    (or a magic watcher) will be able to pause the execution flow for a while (maybe that step is not necessary)
    load the missing data (don't know how to specify, from where to load that data----maybe via attributes) and
    return to the flow.

    My entity objects, do not have a possibility to load the missing data by themselves, because they
    are only data containers having private members, which are accessible via public properties.
    These objects need to be filled with their data from outside, and therefore many lazy loading solutions
    won't work here.

    Maybe anyone of you knows the solution for my problem?

    Thank You in advance!


    Greetz!
    cyberjoe

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Object Factories with Lazy Loading in C#

    Create public properties in your class. When this property is accessed, if the corresponding private variable is null, make a call to the private method that can do the fetching for you. Populate the private member, return it.

    Those are the basics. If this isn't what you want, explain 'These objects need to be filled with their data from outside'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width