Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a suitable NHibernate / Iesi.Collections.Generic.ISet<T> replacement?

In the latest version of Iesi.Collections is missing Iesi.Collections.Generic.ISet. There seem to be three alternatives:

  1. LinkedHashSet
  2. ReadOnlySet
  3. SynchronizedSet

Iesi.Collections.Generic.ReadOnlySet seems to be the closest to the ISet, and the documentation states:

... although it's advertised as immutable it really isn't. 
Anyone with access to the wrapped set can still change the set. 

It seems that the ReadOnlySet is the best replacement for the ISet? Currently the implementation is adding items to a set via public methods so it seems like the best fit. The alternatives (IList, bag?) seem to require more resources or are not as quick/efficient)? Is there a better alternative? (The list shouldn't have duplicates, which could be verified manually)

I'll do stuff like:

public virtual ISet<MyClass> MyClass
{
    get { return this.myClass }
}

public virtual void AddItem(MyClass item)
{
    ... // Null checks and initialize ISet if null
    myClass.Add(item)
}

Basically it boils down to the alternatives, are there alternatives without negative consequences such as in speed etc.?

like image 342
lko Avatar asked Jun 10 '13 07:06

lko


1 Answers

Well, getting Iesi.Collections from Nuget only offers v. 4.

The solution here worked with NHibernate 3.x, but this question will probably be relevant with NHibernate 4+. Issuewith NHibernate, Fluent NHibernate and Iesi.Collection. What would you try next?

I deleted the Iesi reference and added NHibernate which included an old version of Iesi with ISet. It doesn't actually solve the ISet vs. alternative, but it does resolve my issue so I can just continue using ISet.

Perhaps they will add it be NHibernate 4.0 release, or else it will need to be converted at that time.

like image 143
lko Avatar answered Oct 26 '22 23:10

lko