ObservableCollection<ItemPedido> Items
但是现在在 Fluent nHibernate 中我不知道如何使用它。 有没有一种简单的方法可以将 ObservableCollection 与 Fluent nHibernate 一起使用? 我注意到有一个 DLL NHibernate.Collection.Observable;
但我不知道如何替换我当前使用 IList 的代码:
public virtual IList<ItemPedido> Items
{
get { return _Items; }
set { _Items = value; OnPropertyChanged(System.Reflection.MethodBase.GetCurrentMethod().Name.Substring(4)); /*OnPropertyChanged("Items");*/ }
} private IList<ItemPedido> _Items;
如何更改上面的代码,使其与 Observable Collection 和 Fluent nHibernate 一起工作?
最佳答案
继续使用ObservableCollection<T>
作为 IList<T>
的实现- 无需更改业务代码。
您所要做的就是配置 NHibernate 以替换 IList<T>
在执行延迟加载时在内部使用 NhibernateObservableCollection。
我用过
uNhAddIns.WPF.Collections.Types.ObservableListType<T>
来自 Unofficial NHibernate Addins (unhaddins)为了这。
但很可能 NhibernateObservableCollection 的任何其他实现也可以。
在 fluent-nibernate-with-wpf-convention-to-use-unhaddins-observablelisttypet-as-Default你会发现我用 Fluent nHibernate 配置 ObservableCollection 的例子。
如果要使用uNhAddIns.WPF.Collections.Types.ObservableListType<T>
请注意: 没有二进制分发版,所以你必须自己从 c# 源代码编译 uNhAddIns.WPF.dll。
关于c# - 如何在 Fluent nHibernate 中使用 ObservableCollection?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5220920/