本文介绍了什么是合适的NHibernate / Iesi.Collections.Generic.ISet< T>替代?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Iesi.Collections的最新版本缺少Iesi.Collections.Generic.ISet。
似乎有有三种选择:




  1. LinkedHashSet

  2. ReadOnlySet

  3. SynchronizedSet



  4. Iesi.Collections.Generic.ReadOnlySet似乎是最接近的ISet,并且该文档声明:

      ...虽然它标榜为不可变的真的不是。与访问一组包
    任何人都仍然可以改变设置。



    看来,ReadOnlySet是对的ISet的最佳替代?目前,因此它似乎最适合的实现是通过公共的方法将项目添加到一组。这些替代品(IList的,袋?)似乎需要更多的资源或不作为快速/高效)?有没有更好的选择吗? (名单应该不会有重复,这可以手动验证)



    我会做的东西,如:

      public虚拟的ISet< MyClass的> MyClass的
    {
    {返回this.myClass}
    }

    公共虚拟无效的AddItem(MyClass的项目)
    {
    ... // null检查和初始化的ISet如果为null
    myClass.Add(项目)
    }

    基本上它归结为替代品,是没有消极后果有替代品,如速度等。


    解决方案

    好从获得的NuGet仅Iesi.Collections提供诉4.



    这里的解决方案与NHibernate 3.x的工作,但这个问题很可能是相关的与NHibernate 4+。



    我删除了Iesi填入参考,并添加NHibernate的,其中包括与ISet的旧版本Iesi填入的。它实际上并没有解决的ISet与替代,但它确实解决我的问题,所以我就可以继续使用的ISet。



    也许他们会添加它是NHibernate的4.0版本,否则将需要在那个时候进行转换。


    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.?

    解决方案

    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.

    这篇关于什么是合适的NHibernate / Iesi.Collections.Generic.ISet&LT; T&GT;替代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 00:32