Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 46a7e8d

Browse files
committed
Add support for <> in VB.NET
1 parent b151c8b commit 46a7e8d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/ServiceStack.OrmLite/Expressions/SqlExpression.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,14 +1053,14 @@ protected virtual object VisitBinary(BinaryExpression b)
10531053
if (right as PartialSqlString == null)
10541054
right = ((bool)right) ? GetTrueExpression() : GetFalseExpression();
10551055
}
1056-
else if (operand == "=" && b.Left is MethodCallExpression && ((MethodCallExpression)b.Left).Method.Name == "CompareString")
1056+
else if ((operand == "=" || operand == "<>") && b.Left is MethodCallExpression && ((MethodCallExpression)b.Left).Method.Name == "CompareString")
10571057
{
10581058
//Handle VB.NET converting (x => x.Name == "Foo") into (x => CompareString(x.Name, "Foo", False)
10591059
var methodExpr = (MethodCallExpression)b.Left;
10601060
var args = this.VisitExpressionList(methodExpr.Arguments);
10611061
object quotedColName = args[0];
10621062
object value = GetValue(args[1], typeof(string));
1063-
return new PartialSqlString("(" + quotedColName + " = " + value + ")");
1063+
return new PartialSqlString("({0} {1} {2})".Fmt(quotedColName, operand, value));
10641064
}
10651065
else
10661066
{

tests/ServiceStack.OrmLite.VbNetTests/Class1.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Module Module1
2828

2929
Dim q As SqlExpression(Of Poco) = db.From(Of Poco)()
3030

31-
q.Where(Function(x) x.Name = "Foo")
31+
q.Where(Function(x) x.Name <> "Bar")
3232

3333
Dim rows As List(Of Poco) = db.Select(q)
3434

0 commit comments

Comments
 (0)