无法执行Nhibernate查询

时间:2012-03-23 21:59:27

标签: c# nhibernate

我收到以下Nhiberante错误,但不明白为什么:

  

无法执行查询[select attachment0_.AttachmentId as   Attachme1_9_,attachment0_.Name作为Name9_,attachment0_.IconUrl as   IconUrl9_,attachment0_.UserId为UserId9_,   attachment0_.AttachmentTypeId as Attachme6_9_,attachment0_.IsDeleted   as IsDeleted9_,attachment0_.ArrivalTime as ArrivalT8_9_,   attachment0_.LocationId作为Attachment_Attachment中的LocationId9_   attachment0_ where attachment0_.DYNAMIC_TYPE ='附件'和1 = 0]   [SQL:选择attachment0_.AttachmentId作为Attachme1_9_,   attachment0_.Name作为Name9_,attachment0_.IconUrl作为IconUrl9_,   attachment0_.UserId as UserId9_,attachment0_.AttachmentTypeId as   Attachme6_9_,attachment0_.IsDeleted as IsDeleted9_,   attachment0_.ArrivalTime as ArrivalT8_9_,attachment0_.LocationId as   来自Attachment_Attachment attachment0_的LocationId9_   attachment0_.DYNAMIC_TYPE ='附件'和1 = 0]

更新

内部异常:

Failed to convert parameter value from a WhereSelectListIterator`2 to a Guid.

我的查询:

x => locationsIds.Contains(x.LocationId)

3 个答案:

答案 0 :(得分:3)

locationsIds可能是通过调用Where返回的IEnumerable。最简单的解决方案是将其显式转换为列表:

var idsList = locationIds.ToList();
x => idsList.Contains(x.LocationId);

答案 1 :(得分:1)

检查InnerException。我相信它会把你指向正确的地方。

答案 2 :(得分:0)

我知道这个具体的问题已在这里得到解答,但我也有这个例外(使用不同的列名),失败的原因是我使用了错误的数据库。我在一个数据库中添加了一个新表,但是当我运行代码时,我已将其配置为使用另一个数据库。一旦我使用了正确的数据库,错误就消失了。

我希望这有助于某人!

相关问题