I have two classes: container which contains dynamic ordered list of Element.
What C# collection should I use?
What DB schema would you suggest me?
How should I configure the nhibernate mapping?
TIA
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
NHibernate supports collections implemented by System.Collections.SortedList and Iesi.Collections.SortedSet. You must specify a comparer in the mapping file:
Allowed values of the sort attribute are unsorted, natural and the name of a class implementing System.Collections.IComparer.
If you want the database itself to order the collection elements use the order-by attribute of set, bag or map mappings. This performs the ordering in the SQL query, not in memory.
Setting the order-by attribute tells NHibernate to use ListDictionary or ListSet class internally for dictionaries and sets, maintaining the order of the elements. Note that lookup operations on these collections are very slow if they contain more than a few elements.
Note that the value of the order-by attribute is an SQL ordering, not a HQL ordering!
Associations may even be sorted by some arbitrary criteria at runtime using a Filter().
Source:
NHibernate and Sorted Collections