0

I get the following Nhiberante error, but have no idea why:

could not execute query [ select attachment0_.AttachmentId as Attachme1_9_, attachment0_.Name as Name9_, attachment0_.IconUrl as IconUrl9_, attachment0_.UserId as UserId9_, attachment0_.AttachmentTypeId as Attachme6_9_, attachment0_.IsDeleted as IsDeleted9_, attachment0_.ArrivalTime as ArrivalT8_9_, attachment0_.LocationId as LocationId9_ from Attachment_Attachment attachment0_ where attachment0_.DYNAMIC_TYPE='Attachment' and 1=0 ] [SQL: select attachment0_.AttachmentId as Attachme1_9_, attachment0_.Name as Name9_, attachment0_.IconUrl as IconUrl9_, attachment0_.UserId as UserId9_, attachment0_.AttachmentTypeId as Attachme6_9_, attachment0_.IsDeleted as IsDeleted9_, attachment0_.ArrivalTime as ArrivalT8_9_, attachment0_.LocationId as LocationId9_ from Attachment_Attachment attachment0_ where attachment0_.DYNAMIC_TYPE='Attachment' and 1=0]

Update:

inner exception:

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

My query:

x => locationsIds.Contains(x.LocationId)
5
  • 1
    Check the InnerException Commented Mar 23, 2012 at 22:02
  • This is not enough info to go, please provide more... Commented Mar 24, 2012 at 6:58
  • Failed to convert parameter value from a WhereSelectListIterator`2 to a Guid. Commented Mar 28, 2012 at 20:25
  • What type is locationsIds? Also, I'm sure not nHibernate can handle this type of query, essentially a WHERE [field] in [LIST] where list is a variable. Commented Mar 28, 2012 at 21:10
  • @ Rich ids are guid. How can I verify what is applicable linq by NH? Commented Mar 29, 2012 at 15:55

3 Answers 3

3

locationsIds is probably an IEnumerable returned by a call to Where. The simplest solution is to explicitly convert it to a list:

var idsList = locationIds.ToList();
x => idsList.Contains(x.LocationId);
Sign up to request clarification or add additional context in comments.

Comments

1

Check the InnerException. I'm sure it will point you to the correct place.

1 Comment

Failed to convert parameter value from a WhereSelectListIterator`2 to a Guid. Any idea?
0

I know this specific question have been answered here, but I have also had this exception (with different column names) and the reason it failed was that I had used the wrong database. I had added a new table to one database, but when I ran the code I had configured it to use another database. Once I used the correct database the error disappeared.

I hope this helps someone!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.