2012-03-23 31 views
0

我得到以下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) 
+1

檢查InnerException – 2012-03-23 22:02:46

+0

這是沒有足夠的信息去,請提供更多... – Rippo 2012-03-24 06:58:25

+0

無法將參數值從WhereSelectListIterator'2轉換爲Guid。 – 2012-03-28 20:25:24

回答

1

檢查InnerException。我相信它會把你指向正確的地方。

+0

無法將參數值從WhereSelectListIterator'2轉換爲Guid。任何想法? – 2012-03-28 20:25:18

3

locationsIds可能是通過調用Where返回的IEnumerable。最簡單的辦法是明確地將其轉換爲一個列表:

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

我知道這個具體的問題已經在這裏找到答案,但我也有過這樣的異常(具有不同列名),它失敗的原因是,我使用了錯誤的數據庫。我爲一個數據庫添加了一個新表,但是當我運行代碼時,我已經配置它來使用另一個數據庫。一旦我使用了正確的數據庫,錯誤就消失了。

我希望這可以幫助別人!

相關問題