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

Commit 2ad45af

Browse files
author
Oleg Nadymov
committed
Fix for CheckExpressionForTypes (checking of MethodCallExpression )
1 parent 92e92c9 commit 2ad45af

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/ServiceStack.OrmLite/Expressions/SqlExpression.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,9 +1525,12 @@ protected bool CheckExpressionForTypes(Expression e, ExpressionType[] types)
15251525
{
15261526
for (var i = 0; i < methodCallExpr.Arguments.Count; i++)
15271527
{
1528-
if (CheckExpressionForTypes(methodCallExpr.Arguments[0], types))
1528+
if (CheckExpressionForTypes(methodCallExpr.Arguments[i], types))
15291529
return true;
15301530
}
1531+
1532+
if (CheckExpressionForTypes(methodCallExpr.Object, types))
1533+
return true;
15311534
}
15321535

15331536
var unaryExpr = e as UnaryExpression;

tests/ServiceStack.OrmLite.Tests/ExpressionVisitorTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,17 @@ public void Can_Where_using_SqlIn_filter()
564564
Assert.That(target.Count, Is.EqualTo(1));
565565
}
566566

567+
[Test]
568+
public void Can_Where_using_IfConcat_filter()
569+
{
570+
System.Linq.Expressions.Expression<Func<TestType, bool>> filter = x => (String.Concat("Text: ", x.TextCol) == null ? null : String.Concat("Text: ", x.TextCol)).EndsWith("asdf");
571+
var q = Db.From<TestType>().Where(filter);
572+
Assert.That(q.ToSelectStatement(), Does.Contain("Text"));
573+
574+
var target = Db.Select(q);
575+
Assert.That(target.Count, Is.EqualTo(1));
576+
}
577+
567578
private int MethodReturningInt(int val)
568579
{
569580
return val;

0 commit comments

Comments
 (0)