i'm pretty sure LIKE works with strings, not integers. does the query work outside of NH?
On Sep 23, 3:59 pm, roend <[email protected]> wrote: > Hi, > > I'm having a problem trying to get NHibernate.Linq to generate a > 'like' query on an integer column. The SQL that I'd like it to > produce is: > > select IntegerColumn > from Table > where IntegerColumn like '%StringValue%' > > I've tried using the following code: > > from entity in _session.Linq<Entity> > where entity.IntegerColumn.ToString().Contains(StringValue) > select entiry.IntegerColumn > > This code throws an ArgumentOutOfRangeException. See the stack trace > below. > > Is there any way that I can do this using a Linq expression? > > Thanks, > Nathan > > STACK TRACE: > at System.ThrowHelper.ThrowArgumentOutOfRangeException > (ExceptionArgument argument, ExceptionResource resource) > at System.ThrowHelper.ThrowArgumentOutOfRangeException() > at System.SZArrayHelper.get_Item[T](Int32 index) > at System.Collections.ObjectModel.ReadOnlyCollection`1.get_Item > (Int32 index) > at NHibernate.Linq.Visitors.MemberNameVisitor.VisitMethodCall > (MethodCallExpression expr) > at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) > at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit > (Expression exp) > at NHibernate.Linq.Visitors.MemberNameVisitor.GetMemberName > (ICriteria rootCriteria, Expression expr) > at NHibernate.Linq.Visitors.WhereArgumentsVisitor.GetLikeCriteria > (MethodCallExpression expr, MatchMode matchMode) > at NHibernate.Linq.Visitors.WhereArgumentsVisitor.VisitMethodCall > (MethodCallExpression expr) > at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) > at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit > (Expression exp) > at NHibernate.Linq.Visitors.ExpressionVisitor.VisitLambda > (LambdaExpression lambda) > at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) > at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit > (Expression exp) > at NHibernate.Linq.Visitors.WhereArgumentsVisitor.VisitUnary > (UnaryExpression expr) > at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) > at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit > (Expression exp) > at NHibernate.Linq.Visitors.WhereArgumentsVisitor.GetCriterion > (ICriteria rootCriteria, ISession session, Expression expression) > at NHibernate.Linq.Visitors.RootVisitor.HandleWhereCall > (MethodCallExpression call) > at NHibernate.Linq.Visitors.RootVisitor.VisitMethodCall > (MethodCallExpression expr) > at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) > at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit > (Expression exp) > at NHibernate.Linq.Visitors.RootVisitor.VisitMethodCall > (MethodCallExpression expr) > at NHibernate.Linq.Visitors.ExpressionVisitor.Visit(Expression exp) > at NHibernate.Linq.Visitors.NHibernateExpressionVisitor.Visit > (Expression exp) > at NHibernate.Linq.Visitors.NHibernateQueryTranslator.Translate > (Expression expression, QueryOptions queryOptions) > at NHibernate.Linq.NHibernateQueryProvider.TranslateExpression > (Expression expression) > at NHibernate.Linq.NHibernateQueryProvider.Execute(Expression > expression) > at NHibernate.Linq.Query`1.GetEnumerator() > at System.Collections.Generic.List`1..ctor(IEnumerable`1 > collection) > at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) > at MyApplication.Controller.MyMethod(String q, Int32 limit) in c: > \MyFile\Controller.cs:line 30 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
