本文介绍了Is Iesi.Collections.Generic.LinkedHashSet<T>Iesi.Collections.Generic.ISet<T>的最佳替代方案在迁移到 NHibernate 4.0.3.4000 时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我用最新版本 4.0.3.4000 升级了我的 NHibernate 库.在那之后 - 在编译期间我遇到了一个与Iesi.Collections.Generic.ISet"相关的问题.从细节中我了解到 - 此接口已删除并且备用选项可用 - 其中之一是 LinkedHashSet.

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.

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

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

推荐答案

本文来自 发行说明:

** 从 NH3.3.3.GA 到 4.0.0.GA 的已知突破性变化

NHibernate 现在面向 .Net 4.0.Iesi.Collections 中集合类型的许多用途现在已更改为使用 BCL 中的相应类型.这些类型的 API 略有不同.

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>

以及作为它的实现,甚至是 System 内置类型,例如

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

System.Collections.Generic.HashSet<T>

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

And therefore reduce dependency on iesi library...

但正如这里所讨论的:什么是合适的NHibernate/Iesi.Collections.Generic.ISet替换? - 我们也可以使用LinkedHashSetReadOnlySetSynchronizedSet

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>

还要检查 Customer.cs 在 NHibernate 测试项目中:

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

这篇关于Is Iesi.Collections.Generic.LinkedHashSet&amp;lt;T&gt;Iesi.Collections.Generic.ISet&lt;T&gt;的最佳替代方案在迁移到 NHibernate 4.0.3.4000 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 00:32