如何使用的ObservableCollection与功能NHibernate? [英] How to use ObservableCollection with Fluent nHibernate?
问题描述
ObservableCollection<ItemPedido> Items
但是,现在在功能NHibernate我不知道如何使用它。
是否有与功能NHibernate使用的ObservableCollection一个简单的方法?
我注意到有一个DLL NHibernate.Collection.Observable;
But now in Fluent nHibernate i don´t know how to use it. Is there an easy way to use ObservableCollection with Fluent nHibernate? I noticed there is a DLL NHibernate.Collection.Observable;
但我不知道如何来取代我当前的代码使用的IList:
But i don´t know how to replace my current code that uses 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;
如何更改上面的代码,使其与观察到的集合和功能NHibernate?
how to change the above code to make it work with Observable Collection and Fluent nHibernate?
推荐答案
请使用的ObservableCollection< T>
的实施的IList的< T>
- 无需修改业务代码。
Keep on using ObservableCollection<T>
as implementation of IList<T>
- no need to change the business code.
所有你需要做的是配置NHibernate的更换的IList< T>
内部与NhibernateObservableCollection做的时候延迟加载。
All you have to do is configure NHibernate to replace the IList<T>
internally with an NhibernateObservableCollection when doing the lazy loading.
我用
uNhAddIns.WPF.Collections.Types.ObservableListType<T>
从的非官方NHibernate的加载项(unhaddins)这一点。
但probaly任何其他实施NhibernateObservableCollection会做的一样好
But probaly any other implementation of NhibernateObservableCollection will do as well.
目前的fluent-nibernate-with-wpf-convention-to-use-unhaddins-observablelisttypet-as如果你想使用 - 默认你找到我用来配置与功能NHibernate的的ObservableCollection的例子。
At fluent-nibernate-with-wpf-convention-to-use-unhaddins-observablelisttypet-as-Default you find the example i used to configure the ObservableCollection with Fluent nHibernate.
请注意 uNhAddIns.WPF .Collections.Types.ObservableListType< T>
:目前对此没有二进制分发版,所以你必须自己从C#源代码编译uNhAddIns.WPF.dll。
Note if you want to use uNhAddIns.WPF.Collections.Types.ObservableListType<T>
: There is no binary distribution for this so you have to compile uNhAddIns.WPF.dll yourself from c# sourcecode.
这篇关于如何使用的ObservableCollection与功能NHibernate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!