Jan*_*Jan 9 c# nhibernate proxy-classes
我正在使用NHibernate(2.0.1.4)与NHibernate.Linq(1.0.0.4)从数据库中获取Node类型的对象.
当我得到这些对象时,我得到的集合的最后一个对象是Proxy类型(因为我使用了"NHibernate.ByteCode.LinFu"")
我使用了以下linq查询:
var mynodes = from node in session.Linq<Node>() where ancestorNodes.Contains(node.Id) select node).ToList()
Run Code Online (Sandbox Code Playgroud)
anchestorNodes是要获取的节点对象的Id列表.
当我在"ancestorNodes"列表中有3个id时,我从查询中获得的结果(mynodes)的最后一个对象是nodeProxy类型.
怎么会这样?为什么它总是最后一个对象?我怎么解决这个问题?
PB.*_*PB. 17
如果您的Proxy对象实现了INhibernateProxy,您可以使用以下代码使用NHibernate取消对象:
iAmaSession.GetSessionImplementation().PersistenceContext.Unproxy(iAmaProxy)
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助!