无法执行NHibernate的查询
我得到以下Nhiberante错误,但不知道为什么:无法执行NHibernate的查询
无法执行查询[选择attachment0_.AttachmentId为 Attachme1_9_,attachment0_.Name为Name9_,attachment0_.IconUrl为 IconUrl9_,attachment0_.UserId如UserId9_, attachment0_.AttachmentTypeId如Attachme6_9_,attachment0_.IsDeleted 如IsDeleted9_,attachment0_.ArrivalTime如ArrivalT8_9_, attachment0_.LocationId如LocationId9_从Attachment_Attachment attachment0_其中attachment0_.DYNAMIC_TYPE = '附件' 和1 = 0 ] [SQL:选择attachment0_.AttachmentId如Attachme1_9_, attachment0_.Name如Name9_,attachment0_.IconUrl如IconUrl9_, attachment0_.UserId如UserId9_,attachment0_.AttachmentTypeId如 Attachme6_9_,attachment0_.IsDeleted如IsDeleted9_, attachment0_.ArrivalTime如ArrivalT8_9_ ,attachment0_.LocationId从Attachment_Attachment attachment0_其中 attachment0_.DYNAMIC_TYPE = '附件' 和1 = 0]
更新 LocationId9_:
内部异常:
Failed to convert parameter value from a WhereSelectListIterator`2 to a Guid.
我的查询:
x => locationsIds.Contains(x.LocationId)
检查InnerException
。我相信它会把你指向正确的地方。
无法将参数值从WhereSelectListIterator'2转换为Guid。任何想法? – 2012-03-28 20:25:18
locationsIds
可能是通过调用Where
返回的IEnumerable。最简单的办法是明确地将其转换为一个列表:
var idsList = locationIds.ToList();
x => idsList.Contains(x.LocationId);
我知道这个具体的问题已经在这里找到答案,但我也有过这样的异常(具有不同列名),它失败的原因是,我使用了错误的数据库。我为一个数据库添加了一个新表,但是当我运行代码时,我已经配置它来使用另一个数据库。一旦我使用了正确的数据库,错误就消失了。
我希望这可以帮助别人!
检查InnerException – 2012-03-23 22:02:46
这是没有足够的信息去,请提供更多... – Rippo 2012-03-24 06:58:25
无法将参数值从WhereSelectListIterator'2转换为Guid。 – 2012-03-28 20:25:24