InterviewSolution
| 1. |
How Do I Translate The Nhibernate Collections To .net Collections? |
|
Answer» The names of the collection mappings is one obvious place where the differences between Java and .NET are shown. Java's collection library has many more options than System.Collection does.
If an order-by attribute is added to the collection mapping element then the concrete collection type will change to one that supports maintaining the order an element was added. For a <bag> it still uses an ArrayList. For the <map> and <set> that have an order-by attribute the concrete collection class changes to a Specialized.ListDictionary and Iesi.Collections.ListSet, respectively. This should be a non-issue since the consumers of your API are using the interfaces IList and Iesi.Collections.ISet. If a SORT attribute is added to the collection mapping element then the concrete collection type will change to one that supports ordering. For the <map> and <set> that have a sort attribute the concrete collection class changes to a SortedList or Iesi.Collections.SortedSet, respectively, that uses the IComparer provided in the sort attribute. This should be a non-issue to the consumers of your API since they are using the interfaces IList and Iesi.Collections.ISet. Using an order-by or sort attribute does have implications on performance for maps and sets as the size of the collections grows. Please read the MSDN documentation about the ListDictionary and SortedList performance implications. There are also some good articles on The Code Project about collections. The names of the collection mappings is one obvious place where the differences between Java and .NET are shown. Java's collection library has many more options than System.Collection does. If an order-by attribute is added to the collection mapping element then the concrete collection type will change to one that supports maintaining the order an element was added. For a <bag> it still uses an ArrayList. For the <map> and <set> that have an order-by attribute the concrete collection class changes to a Specialized.ListDictionary and Iesi.Collections.ListSet, respectively. This should be a non-issue since the consumers of your API are using the interfaces IList and Iesi.Collections.ISet. If a sort attribute is added to the collection mapping element then the concrete collection type will change to one that supports ordering. For the <map> and <set> that have a sort attribute the concrete collection class changes to a SortedList or Iesi.Collections.SortedSet, respectively, that uses the IComparer provided in the sort attribute. This should be a non-issue to the consumers of your API since they are using the interfaces IList and Iesi.Collections.ISet. Using an order-by or sort attribute does have implications on performance for maps and sets as the size of the collections grows. Please read the MSDN documentation about the ListDictionary and SortedList performance implications. There are also some good articles on The Code Project about collections. |
|