0

Since upgrading from NH 3.0 to 3.1 I've been having some trouble using the following code:

 criteria = session.CreateCriteria<User>()
    .Add(SqlExpression.InG<User, int>(user => user.ID, toBeFechted)); // toBefetched is an IList<int>

This will compile fine but when running it I get an exception as soon as I add the In condition to the criteria.

System.MissingMethodException : Method not found: NHibernate.Criterion.AbstractCriterion NHibernate.Criterion.Restrictions.InG(System.String, System.Collections.Generic.ICollection1<**UNKNOWN TYPE**>). at NHibernate.LambdaExtensions.SqlExpression.InG(Expression1 expression, ICollection`1 values)

I can rebuild the query using QueryOver instead of Criteria and it will work, but doing that requires digging up alot of code that I don't have the time to do. Using NH 3.0 I did not have the problem.

Has something changed in NH 3.1 or am I having some weird dll problem?

ds99jove
  • 618
  • 2
  • 7
  • 21
  • I've seen this exception when deploying some assemblies in GAC. I you don't increment the version with any change you make you will get a MissingMethod Exception. Don't know how this could happen when using nhibernate, but you should check anyway. Also you should check if using Fluent/Old linq/old cache prividers that they are all compiled with NH 3.1 – Iulian Margarintescu Mar 31 '11 at 13:09
  • I'm not sure how to check that. I haven't done anything with the GAC as far as I know. I also managed to do a successful query using .Add(SqlExpression.IsNotNull(x => x.ID)); SqlExpression is part of LambdaExtensions and I was suspecting that there was something wrong with this reference, but it appears there isn't. – ds99jove Mar 31 '11 at 14:45
  • I backed down to NH 3.0 and everything started working again. – ds99jove Apr 01 '11 at 06:08
  • I backed down to NH 3.0 and everything started working again. In the process I learned that in NH 3.0 you can use stateless session and QueryOver. Even though IStatelessSession is missing the QueryOver method you can do a detached queryover which then can call GetExecutableQueryOver(session). I'm not sure whether my problem is because of a bug or something weird in my setup. Unfortunatly we'll have to be very carefull when upgrading NH in the future. – ds99jove Apr 01 '11 at 07:39
  • If you could provide a sample project reproducing the behavior with NH 3.1 someone might be able to provide better input. ATM i'm out of suggestions, sorry. – Iulian Margarintescu Apr 01 '11 at 08:36

1 Answers1

1

If you are using the Googlecode older style NH Lambda Extensions which were built on NH 2.1 assemblies, you have 2 options; - you can downgrade to 3.0 as you have or you can download the sourcecode and compile against the later binaries.

If you dont want to do this, I have a copy of NHlambdaextensions built against NH3.1, which includes all of the original tests passing to give you some coverage

Mark H
  • 707
  • 1
  • 11
  • 21