Automap IList<T> as list (instead of bag) as a convention

Jacob Madsen's Avatar

Jacob Madsen

28 Aug, 2010 12:06 PM via web

Hi there,

I have a criteria where it would be a great help, if IList was mapped as list instead of bag.
Is it possible to define a convention for this?

public class ListConvention : IHasManyConvention, IHasManyConventionAcceptance
{

public void Apply(IOneToManyCollectionInstance instance)
{
    // use list instead of bag
}

public void Accept(IAcceptanceCriteria<IOneToManyCollectionInspector> criteria)
{
    // my criteria
}

}

With ClassMap its possible to say "AsList()", but I cant locate something equal with the automapper.

  1. Support Staff 2 Posted by Paul Batum on 29 Aug, 2010 12:47 AM

    Paul Batum's Avatar

    This is a known limitation unfortunately. Until we change how the different
    collection types are implemented, you won't be able to do this.

    On Sat, Aug 28, 2010 at 10:08 PM, Jacob Madsen <
    tender+d4afd2f15ee4650cbeeb13d614903479e516debff@tenderapp.com<tender%2Bd4afd2f15ee4650cbeeb13d614903479e516debff@tenderapp.com>
    > wrote:

  2. 3 Posted by Jacob Madsen on 30 Aug, 2010 09:12 AM

    Jacob Madsen's Avatar

    Is it possible to do in some ugly way on the current exposed interfaces? The criteria is not important.

  3. Support Staff 4 Posted by James Gregory on 30 Aug, 2010 09:37 AM

    James Gregory's Avatar

    IAutomappingOverridr<T> will allow you to do it on a per-entity basis, but it won't be nice.

    This is quite a high priority change for the next release.

  4. 5 Posted by Jacob Madsen on 30 Aug, 2010 10:08 AM

    Jacob Madsen's Avatar

    I am always looking forward to new releases of cool projects like FNH :-)

    I can override automap of a base type and implement my criteria with some reflection magic and then call the AsList() when needed. Would you agree that this could be a (very ugly) possible solution for now?

  5. Support Staff 6 Posted by James Gregory on 30 Aug, 2010 11:31 AM

    James Gregory's Avatar

    In theory, that sounds like it'd work :)

    I've just started work on fixing this issue, but it may take a little while
    as it does require some significant restructuring internally.

    On Mon, Aug 30, 2010 at 11:11 AM, Jacob Madsen <
    tender+d4afd2f15ee4650cbeeb13d614903479e516debff@tenderapp.com<tender%2Bd4afd2f15ee4650cbeeb13d614903479e516debff@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 number comes after 20?