mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-08 18:34:55 +08:00
Update Expression To Sql
This commit is contained in:
@@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public class SubAvg: ISubOperation
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Avg";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 "AVG(" + SubTools.GetMethodValue(this.Context, exp.Arguments[0], ResolveExpressType.FieldSingle) + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public class SubSum:ISubOperation
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Sum";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 "SUM("+SubTools.GetMethodValue(this.Context, exp.Arguments[0], ResolveExpressType.FieldSingle)+")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,10 +21,15 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TResult Select<TResult>(Func<T, TResult> expression) where TResult :struct
|
public TResult Select<TResult>(Func<T, TResult> expression) where TResult :struct
|
||||||
{
|
{
|
||||||
return default(TResult);
|
return default(TResult);
|
||||||
}
|
}
|
||||||
|
public Byte[] Select(Func<T, Byte[]> expression)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
public string Select(Func<T, string> expression)
|
public string Select(Func<T, string> expression)
|
||||||
{
|
{
|
||||||
return default(string);
|
return default(string);
|
||||||
@@ -34,19 +39,54 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return default(TResult);
|
return default(TResult);
|
||||||
}
|
}
|
||||||
|
public Byte[] Max(Func<T, Byte[]> expression)
|
||||||
public TResult Min<TResult>(Func<T, TResult> expression) where TResult : struct
|
|
||||||
{
|
{
|
||||||
return default(TResult);
|
return null;
|
||||||
}
|
}
|
||||||
public string Max(Func<T, string> expression)
|
public string Max(Func<T, string> expression)
|
||||||
{
|
{
|
||||||
return default(string);
|
return default(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Min(Func<T, string> expression)
|
public string Min(Func<T, string> expression)
|
||||||
{
|
{
|
||||||
return default(string);
|
return default(string);
|
||||||
}
|
}
|
||||||
|
public TResult Min<TResult>(Func<T, TResult> expression) where TResult : struct
|
||||||
|
{
|
||||||
|
return default(TResult);
|
||||||
|
}
|
||||||
|
public Byte[] Min(Func<T, Byte[]> expression)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string Sum(Func<T, string> expression)
|
||||||
|
{
|
||||||
|
return default(string);
|
||||||
|
}
|
||||||
|
public TResult Sum<TResult>(Func<T, TResult> expression) where TResult : struct
|
||||||
|
{
|
||||||
|
return default(TResult);
|
||||||
|
}
|
||||||
|
public Byte[] Sum(Func<T, Byte[]> expression)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Avg(Func<T, string> expression)
|
||||||
|
{
|
||||||
|
return default(string);
|
||||||
|
}
|
||||||
|
public TResult Avg<TResult>(Func<T, TResult> expression) where TResult : struct
|
||||||
|
{
|
||||||
|
return default(TResult);
|
||||||
|
}
|
||||||
|
public Byte[] Avg(Func<T, Byte[]> expression)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public bool Any()
|
public bool Any()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,6 +87,8 @@
|
|||||||
<Compile Include="ExpressionsToSql\Subquery\Items\SubFromTable.cs" />
|
<Compile Include="ExpressionsToSql\Subquery\Items\SubFromTable.cs" />
|
||||||
<Compile Include="ExpressionsToSql\Subquery\Items\SubAny.cs" />
|
<Compile Include="ExpressionsToSql\Subquery\Items\SubAny.cs" />
|
||||||
<Compile Include="ExpressionsToSql\Subquery\Items\SubBegin.cs" />
|
<Compile Include="ExpressionsToSql\Subquery\Items\SubBegin.cs" />
|
||||||
|
<Compile Include="ExpressionsToSql\Subquery\Items\SubAvg.cs" />
|
||||||
|
<Compile Include="ExpressionsToSql\Subquery\Items\SubSum.cs" />
|
||||||
<Compile Include="ExpressionsToSql\Subquery\Items\SubMin.cs" />
|
<Compile Include="ExpressionsToSql\Subquery\Items\SubMin.cs" />
|
||||||
<Compile Include="ExpressionsToSql\Subquery\Items\SubMax.cs" />
|
<Compile Include="ExpressionsToSql\Subquery\Items\SubMax.cs" />
|
||||||
<Compile Include="ExpressionsToSql\Subquery\Items\SubOrderBy.cs" />
|
<Compile Include="ExpressionsToSql\Subquery\Items\SubOrderBy.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user