Skip to content

Commit e269ebc

Browse files
committed
#41 max method is supported
1 parent 39893cf commit e269ebc

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

SubSonic.Tests/DAL/ExtensionMethod/ExtensionMethodTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ protected override void SetSelectBehaviors()
2222

2323
string
2424
person_min = @"SELECT MIN([T1].[ID])
25+
FROM [dbo].[Person] AS [T1]",
26+
person_max = @"SELECT MAX([T1].[ID])
2527
FROM [dbo].[Person] AS [T1]";
2628

29+
Context.Database.Instance.AddCommandBehavior(person_max, cmd => People.Max(x => x.ID));
2730
Context.Database.Instance.AddCommandBehavior(person_min, cmd => People.Min(x => x.ID));
2831
}
2932

@@ -45,5 +48,11 @@ public void TheMinMethodIsSupported()
4548
{
4649
Context.People.Min(x => x.ID).Should().Be(1);
4750
}
51+
52+
[Test]
53+
public void TheMaxMethodIsSupported()
54+
{
55+
Context.People.Max(x => x.ID).Should().Be(People.Count);
56+
}
4857
}
4958
}

SubSonic/Infrastructure/Builders/DbSqlQueryBuilder/DbSqlQueryBuilderQueryProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public TResult ExecuteMethod<TResult>(MethodCallExpression call)
9191
throw Error.InvalidOperation($"Method {call.Method.Name} expects data.");
9292
}
9393
}
94-
else if (call.Method.Name.In(nameof(Queryable.Count), nameof(Queryable.LongCount), nameof(Queryable.Min)))
94+
else if (call.Method.Name.In(nameof(Queryable.Count), nameof(Queryable.LongCount), nameof(Queryable.Min), nameof(Queryable.Max)))
9595
{
9696
if (BuildSelect(dbSelect, where) is DbSelectExpression select)
9797
{

0 commit comments

Comments
 (0)