我想使用ServiceStack.OrmLite在LIKE
列上进行sql INT
比较。基本上我需要OrmLite来生成以下sql where子句:
where intColumn like '%123%'
我知道我可以在.Contains()
上使用strings
,但我的属性/列是int
。
在.ToString().Contains()
属性上使用int
也会引发以下异常:
System.NotSupportedException: Specified method is not supported.
at ServiceStack.OrmLite.SqlExpression`1.VisitColumnAccessMethod(MethodCallExpression m)
at ServiceStack.OrmLite.SqlExpression`1.VisitMethodCall(MethodCallExpression m)
at ServiceStack.OrmLite.SqlExpression`1.Visit(Expression exp)
at ServiceStack.OrmLite.SqlExpression`1.VisitColumnAccessMethod(MethodCallExpression m)
at ServiceStack.OrmLite.SqlExpression`1.VisitMethodCall(MethodCallExpression m)
at ServiceStack.OrmLite.SqlExpression`1.Visit(Expression exp)
at ServiceStack.OrmLite.SqlExpression`1.VisitLambda(LambdaExpression lambda)
at ServiceStack.OrmLite.SqlExpression`1.Visit(Expression exp)
at ServiceStack.OrmLite.SqlExpression`1.AppendToWhere(String condition, Expression predicate)
at ServiceStack.OrmLite.SqlExpression`1.Where(Expression`1 predicate)
有什么想法吗?
答案 0 :(得分:3)
您应该只能附加自定义SQL Where条件:
var results = db.From<Table>(q => q.Where("intColumn like '%123%'"));