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

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

  • LinkedHashSet
  • ReadOnlySet
  • Synchronizedset

Iesi.Collections.Generic.ReadOnlySet is apparently closest to ISet, and the documentation says:

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

ReadOnlySet seems to be the best replacement for ISet? Currently, the implementation adds elements to the set through public methods, so it seems like this is best suited. Alternatives (IList, bag?) Seem to require more resources or not so fast / efficient)? Is there a better alternative? (There should be no duplicates in the list that can be checked manually)

I will do things 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 comes down to alternatives, are there alternatives without negative consequences, for example, in speed, etc.?

+6
source share
2 answers

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

The solution here worked with NHibernate 3.x, but this question is likely to be relevant to NHibernate 4+. Issued by NHibernate, Fluent NHibernate, and Iesi.Collection. What will you try next?

I removed the Iesi link and added NHibernate, which included the old version of Iesi with ISet. This does not actually solve the ISet problem and the alternative, but it fixes my problem, so I can just keep using ISet.

Perhaps they will add it to NHibernate 4.0, otherwise it should be converted at this time.

+4
source

Iesi.Collections v4 for .Net 4. The correct replacement for Iesi 3 ISet is to use ISet, which was included in .Net System.Collections.Generic in .Net4.0.

You usually also use the .Net HashSet class.

The classes left in Iesi in v4 are some case-specific implementations that are rarely used.

+2
source

Source: https://habr.com/ru/post/946925/


All Articles