4

Recently I have upgraded my NHibernate library with latest version 4.0.3.4000. After that - during compilation I faced an issue related to "Iesi.Collections.Generic.ISet". From details I understand that - this interface is dropped off and alternate options are available - one of it is LinkedHashSet.

I would like to know that - is this the best alternate to replace ISet?

user17276
  • 61
  • 2
  • 5

1 Answers1

6

This is from release notes:

** Known BREAKING CHANGES from NH3.3.3.GA to 4.0.0.GA

NHibernate now targets .Net 4.0. Many uses of set types from Iesi.Collections have now been changed to use corresponding types from the BCL. The API for these types are slightly different.

So we can now use interface

System.Collections.Generic.ISet<T>

and as its implementation even the System built in types, e.g.

System.Collections.Generic.HashSet<T>

And therefore reduce dependency on iesi library...

But as discussed here: What is a suitable NHibernate / Iesi.Collections.Generic.ISet<T> replacement? - we can also use the LinkedHashSet<T>, ReadOnlySet<T>, SychronizedSet<T>

Also check the Customer.cs in NHibernate test project:

using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace NHibernate.DomainModel.Northwind.Entities
{
    public class Customer
    {
        private readonly ISet<Order> _orders;

        public Customer()
        {
            _orders = new System.Collections.Generic.HashSet<Order>();
        }
        public virtual ISet<Order> Orders
        {
            get { return _orders; }
        }
        ...
Community
  • 1
  • 1
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
  • Hi Radim, Thanks for the details. I have checked this three alternatives and will be more interested to know - is LinkedHashSet is best alternate for ISet. The only reason I am asking is, I didn't find more details, differences and comparision of these three options. I just read on release note summary that - if we need to use "Order By" on the list then we still should use "Iesi.Collection" library of NHibernate. So, any details/assistance around this will be greatly appreciated. Thanks a lot. – user17276 Feb 17 '15 at 09:34
  • Cannot give you deep comparison. Just my experience... if I can reduce dependency on any third party lib.. tak I DO. So, I do **NOT** use iesi at all and NHibernate is doing **miracles** for me. Hope it helps a bit... – Radim Köhler Feb 17 '15 at 09:41
  • @user17276 The note is in the code documentation of LinkedHashSet: "Enumeration of this set is guaranteed to return the elements in the order they were added." If you need that property, use this class. Otherwise use the regular HashSet. Radim's reply should be marked as Accepted. – Oskar Berggren Jun 05 '16 at 12:33