This commit is contained in:
sunkaixuan
2017-09-17 01:34:44 +08:00
parent 40340b8f32
commit 153eeba936
4 changed files with 93 additions and 1 deletions

View File

@@ -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)+")";
}
}
}

View File

@@ -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) + ")";
}
}
}

View File

@@ -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 }
};
}

View File

@@ -79,6 +79,8 @@
<Compile Include="ExpressionsToSql\Subquery\Items\SubFromTable.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubAny.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubBegin.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubMin.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubMax.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubRightBracket.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubSelect.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubSelectDefault.cs" />