Hi Darren, I've again tested this scenario using your sample declarations (adapted a little to make it run), and in the re-linq test suite, the method call is perfectly inlined.
This is the query: QuerySource.Where (p => p.ID == hh2.InternalUser.CurrentUser.Options.GetOptionValue (206).ToInt()).Select (p => p.ID).FirstOrDefault(); This is what re-linq makes of it: ExecuteSingle<Int32> (from Cook p in TestQueryable<Cook>() where ([p].ID = 206) select [p].ID => FirstOrDefault(), True) So, I really can't reproduce the issue. Maybe something in NHibernate circumvents the partial evaluator? > What i'm going to try to do today is build nhibernate from source and attach > a debugger and look at the expression tree, anything that might be helpful > that i could get you fabian? Check the following items: - Is PartialEvaluatingExpressionTreeVisitor.EvaluateIndependentSubtrees called on the where expression? -- If yes, what's the result? If the result still holds the call to ToInt (ie, it was not evaluated), this would probably be a bug in re- linq. In that case, please follow up with us on "http://www.google.com/ url?sa=D&q=http://groups.google.com/group/re-motion-users" in order to let us reproduce and fix the issue. -- If not, check the QueryParser used by NHibernate. QueryParser.ExpressionTreeParser.Processor should be a CompoundExpressionTreeProcessor containing an instance of PartialEvaluatingExpressionTreeProcessor. If it doesn't, this would be an issue in NHibernate. Regards, Fabian
