与linq查询问题 [英] Problem with linq query
问题描述
lockquote
方法'get_IsReadOnlyInitialized'
在$ b $类型中执行b'NHibernate.Linq.Util.DetachedCriteriaAdapter'
from assembly'NHibernate.Linq,
Version = 1.1.0.1001,Culture = neutral,
PublicKeyToken = null'没有
执行。
有谁知道如何解决这个问题?我尝试了解决方案形式这个页面与模型的上下文,但没有帮助。
这是代码:
使用(var session = NHibernateHelper .OpenSession())
添加
{
var informations =(from i in session< Information>()where i.Text ==some textselect i).ToList();
$ b $ p
$ b如果我不使用其中部分,但如果我使用它,我得到这个错误。我认为这个问题是在NHibernate.Linq.dll中的。
你应该不使用NHibernate。与NHibernate 3.0的Linq.dll! NHibernate 3.0包含了Linq(比旧的扩展dll版本要好得多),只需要使用NHibernate.Linq;并使用
session .Query< T>()
而不是session.Linq< T>()
。I'm trying to use linq to NHibernate (with Fluent NHibernate) but I have problems with linq query. Everytime I try to execute it I get this message :
"Method 'get_IsReadOnlyInitialized' in type 'NHibernate.Linq.Util.DetachedCriteriaAdapter' from assembly 'NHibernate.Linq, Version=1.1.0.1001, Culture=neutral, PublicKeyToken=null' does not have an implementation."
Does anybody know how to fix this problem? I tried with solution form this page with model context but it didn't help.
This is the code:
using(var session = NHibernateHelper.OpenSession()) { var informations = (from i in session<Information>() where i.Text=="some text" select i).ToList(); }
Everything is fine if I don't use the where part but if I use it I get this error. I think that the problem is in NHibernate.Linq.dll
解决方案You should not use NHibernate.Linq.dll with NHibernate 3.0! NHibernate 3.0 has Linq included (a by far better version than the old extension dll), you just need to add
using NHibernate.Linq;
and usesession.Query<T>()
instead ofsession.Linq<T>()
.这篇关于与linq查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!