Can I write an Eager Load Attribute?

Tommy's Avatar

Tommy

02 Sep, 2010 08:45 AM via web

Hello,

I'm using Automapping and looking to get some relationships on a class to load eagerly and others not to for performance reasons. The best way for me to do this IMHO would be to create an attribute and have a convention pick this up and eagerly load those relationships. Is this possible? I know I could override the Automapping for certain classes but that doesn't seem like as good a solution.

Could somebody please point me in the right direction?

Thank you,

Tommy

  1. Support Staff 2 Posted by James Gregory on 02 Sep, 2010 09:03 AM

    James Gregory's Avatar

    As far as I know, eager loading is a query only operation. There's nothing you can specify in the mapping to say a collection should be eager loaded. You can specify that a collection is not lazy, but that isn't the same as eager.

  2. 3 Posted by Tommy on 02 Sep, 2010 09:07 AM

    Tommy's Avatar

    Ah, thanks for the swift reply. Perhaps I'm getting my semantics confused; what exactly is the difference between Not Lazy-Loading and Eager Loading?

    How would I go about writing an attribute based convention to tell a particular property to not lazy-load?

    Thanks again,

    Tommy

  3. Support Staff 4 Posted by Paul Batum on 15 Sep, 2010 05:22 PM

    Paul Batum's Avatar

    Make a class that implements IPropertyConvention and
    IPropertyConventionAcceptance

    In the implementation for Accept, use reflection to determine if the member
    has your attribute.
    In the implementation for Apply, modify the instance accordingly.

    This will ONLY apply to mapped properties. If you want to do the same thing
    for relationships, etc, then you'll have to make conventions with the
    appropriate interfaces (such as ICollectionConvention)

    On Thu, Sep 2, 2010 at 2:09 AM, Tommy <
    ***@tenderapp.com<tender%***@tenderapp.com>
    > wrote:

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What is the opposite of north?