最近我将 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/