开发者

NHibernate Custom List Component Mapping

I'm working with a codebase that has the equivalent to the following:

public class CustomList<T> : List<T>

And then in a subsequent Class

public interface ISomeObject {
    string Name { get; set; }
    CustomList<ISomeOtherObject> SomeOtherObjects { get; set; }
}

Now in the Mapping file for a normal List the xml would be (I've checked this works):

<list name="SomeOtherObjects " table="SomeOtherObject">
    <key column="Id"/>
    <index column="Reference"/>
    <composite-element class="SomeOtherObject" />
</list>

I need to find out what the equivalent xml is for the CustomList. I've googled and searched here until I am blue in the face finding bits and pieces about components and how to map custom collections but so far I've not been able to find enough to get me over this hurdle. I am trialing and erroring like mad开发者_JAVA技巧 with all the different properties so if anyone has a snippet example of how to map a custom list I'd be very greatful.

Cheers.


Your mapping is on the right path, but incomplete. It should look something like this.

<list name="SomeOtherObjects " table="SomeOtherObject">
    <key column="Id"/>
    <index column="Reference"/>
    <composite-element class="SomeOtherObject" >
        <property name="SomeOtherObjectProperty" />
        <!-- More properties that are defined in SomeOtherObject here. -->
    </composite-element>
</list>

This post may help you understand more about collection mapping.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜