Permalink
Browse files

Add support for .Equals() in SqlExpression's

  • Loading branch information...
mythz committed Sep 14, 2018
1 parent df948b3 commit e8761a47a96c23e4fd11fc8334a46058e68630c1
@@ -2660,6 +2660,9 @@ protected virtual object VisitColumnAccessMethod(MethodCallExpression m)
case "ToLower":
statement = $"lower({quotedColName})";
break;
case "Equals":
statement = $"{quotedColName}={ConvertToParam(wildcardArg)}";
break;
case "StartsWith":
statement = !OrmLiteConfig.StripUpperInLike
? $"upper({quotedColName}) like {ConvertToParam(wildcardArg.ToUpper() + "%")}{escapeSuffix}"
@@ -196,6 +196,30 @@ public void Can_select_using_startsWith_with_backtick_in_string()
}
}

[Test]
public void Can_select_using_Equals()
{
var postfix = "postfix";

var expected = new TestType()
{
IntColumn = 7,
BoolColumn = true,
StringColumn = postfix
};

Init(10, expected);

using (var db = OpenDbConnection())
{
var actual = db.Select<TestType>(q => q.StringColumn.Equals(postfix));

Assert.IsNotNull(actual);
Assert.AreEqual(1, actual.Count);
CollectionAssert.Contains(actual, expected);
}
}

[Test]
public void Can_select_using_endsWith()
{

0 comments on commit e8761a4

Please sign in to comment.