generics - 迁移到 NHibernate 4.0.3.4000 时,Iesi.Collections.Generic.LinkedHashSet<T> 是 Iesi.Collections.Generic.ISet<T> 的最佳替代品吗

标签 generics nhibernate

最近我将 NHibernate 库升级到了最新版本 4.0.3.4000。之后 - 在编译期间我遇到了与“Iesi.Collections.Generic.ISet”相关的问题。从细节中我了解到 - 该接口(interface)已被删除,并且可以使用替代选项 - 其中之一是 LinkedHashSet。

我想知道 - 这是替代 ISet 的最佳替代方案吗?

最佳答案

这是来自 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.

现在我们可以使用接口(interface)了

System.Collections.Generic.ISet<T>

及其实现甚至是 System内置类型,例如

System.Collections.Generic.HashSet<T>

因此减少对 iesi 库的依赖...

但正如这里所讨论的:What is a suitable NHibernate / Iesi.Collections.Generic.ISet<T> replacement? - 我们还可以使用LinkedHashSet<T> , ReadOnlySet<T> , SychronizedSet<T>

另请检查 Customer.cs 在 NHibernate 测试项目中:

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; }
        }
        ...

关于generics - 迁移到 NHibernate 4.0.3.4000 时,Iesi.Collections.Generic.LinkedHashSet<T> 是 Iesi.Collections.Generic.ISet<T> 的最佳替代品吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28545542/

相关文章:

NHibernate Linq where 子句 : value in collection

c# - 扩展方法、T的Func和T的List

javascript - typescript :注入(inject)泛型并获取 ES6 模块名称

nhibernate - 为同一个映射表切换数据库

c# - 在同一事务中删除和添加子实体混淆了 nhibernate

nhibernate - 使用按位运算符时 HQL 到 CriteriaQuery

java - 使用 JGraphT 库的 EdgeProvider 类

带链表的 C++ 泛型容器

java - 泛型方法的泛型返回类型

c# - 在NHibernate中,如何删除关联集合的所有元素?