How to match an ordered list in nhibernate?

I have two classes: containerwhich contains a dynamic ordered list Element.

Which C # collection should I use?

What database schema would you offer me?

How do I set up nhibernate mapping?

TIA

+5
source share
1 answer

NHibernate supports collections implemented by System.Collections.SortedList and Iesi.Collections.SortedSet. You must specify the mapping in the mapping file:

<set name="Aliases" table="person_aliases" sort="natural">
    <key column="person"/>
    <element column="name" type="String"/>
</set>

<map name="Holidays" sort="My.Custom.HolidayComparer, MyAssembly" lazy="true">
    <key column="year_id"/>
    <index column="hol_name" type="String"/>
    <element column="hol_date" type="Date"/>
</map>

Valid values ​​for the sort attribute are unsorted, natural, and the name of the class that implements System.Collections.IComparer.

, , order-by , . SQL, .

order-by NHibernate ListDictionary ListSet , . , , .

<set name="Aliases" table="person_aliases" order-by="name asc">
    <key column="person"/>
    <element column="name" type="String"/>
</set>

<map name="Holidays" order-by="hol_date, hol_name" lazy="true">
    <key column="year_id"/>
    <index column="hol_name" type="String"/>
    <element column="hol_date type="Date"/>
</map>

, order-by - SQL, HQL-!

().

sortedUsers = s.Filter( group.Users, "order by this.Name" );

: NHibernate

+5

All Articles