与linq查询问题 [英] Problem with linq query

查看:161
本文介绍了与linq查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用NHibernate的NHibernate(与流利的NHibernate的),但我有LINQ查询的问题。

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 use session.Query<T>() instead of session.Linq<T>().

这篇关于与linq查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆