diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMax.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMax.cs new file mode 100644 index 000000000..12c20bc5d --- /dev/null +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMax.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; + +namespace SqlSugar +{ + public class SubMax:ISubOperation + { + public string Name + { + get + { + return "Max"; + } + } + + public Expression Expression + { + get; set; + } + + + public int Sort + { + get + { + return 200; + } + } + + public ExpressionContext Context + { + get; set; + } + + public string GetValue(Expression expression = null) + { + var exp = expression as MethodCallExpression; + return "MAX("+SubTools.GetMethodValue(this.Context, exp.Arguments[0], ResolveExpressType.FieldSingle)+")"; + } + } +} diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMin.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMin.cs new file mode 100644 index 000000000..32ae0285b --- /dev/null +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubMin.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; + +namespace SqlSugar +{ + public class SubMin: ISubOperation + { + public string Name + { + get + { + return "Min"; + } + } + + public Expression Expression + { + get; set; + } + + + public int Sort + { + get + { + return 200; + } + } + + public ExpressionContext Context + { + get; set; + } + + public string GetValue(Expression expression = null) + { + var exp = expression as MethodCallExpression; + return "MIN(" + SubTools.GetMethodValue(this.Context, exp.Arguments[0], ResolveExpressType.FieldSingle) + ")"; + } + } +} diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/SubTools.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/SubTools.cs index 21af04649..33571f7cb 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/SubTools.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/SubTools.cs @@ -20,7 +20,9 @@ namespace SqlSugar new SubNotAny(){ Context=Context }, new SubBegin(){ Context=Context }, new SubFromTable(){ Context=Context }, - new SubCount(){ Context=Context } + new SubCount(){ Context=Context }, + new SubMax(){ Context=Context }, + new SubMin(){ Context=Context } }; } diff --git a/Src/Asp.Net/SqlSugar/SqlSugar.csproj b/Src/Asp.Net/SqlSugar/SqlSugar.csproj index ff07be160..dec6ce9e1 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugar.csproj +++ b/Src/Asp.Net/SqlSugar/SqlSugar.csproj @@ -79,6 +79,8 @@ + +