mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-01-19 17:51:36 +08:00
Synchronization code
This commit is contained in:
@@ -1031,6 +1031,19 @@ namespace SqlSugar
|
||||
_InQueryable(expression, sqlObj);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> SampleBy(int timeNumber, SampleByUnit timeType)
|
||||
{
|
||||
SampleByUnit sampleBy = timeType;
|
||||
string sql = "SAMPLE BY "+timeNumber + sampleBy.ToString().Substring(0, 1).ToLower();
|
||||
this.QueryBuilder.SampleBy = sql;
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> SampleBy(int timeNumber, string timeType)
|
||||
{
|
||||
string sql = "SAMPLE BY " + timeType;
|
||||
this.QueryBuilder.SampleBy = sql;
|
||||
return this;
|
||||
}
|
||||
public virtual ISugarQueryable<T> OrderBy(string orderFileds)
|
||||
{
|
||||
orderFileds = orderFileds.ToCheckField();
|
||||
|
||||
@@ -16,6 +16,16 @@ namespace SqlSugar
|
||||
#region T2
|
||||
public partial class QueryableProvider<T, T2> : QueryableProvider<T>, ISugarQueryable<T, T2>
|
||||
{
|
||||
public new ISugarQueryable<T, T2> SampleBy(int timeNumber, SampleByUnit timeType)
|
||||
{
|
||||
base.SampleBy(timeNumber, timeType);
|
||||
return this;
|
||||
}
|
||||
public new ISugarQueryable<T, T2> SampleBy(int timeNumber, string timeType)
|
||||
{
|
||||
base.SampleBy(timeNumber, timeType);
|
||||
return this;
|
||||
}
|
||||
public virtual ISugarQueryable<TResult> SelectMergeTable<TResult>(Expression<Func<T,T2, TResult>> expression)
|
||||
{
|
||||
return this.Select(expression).MergeTable();
|
||||
@@ -613,6 +623,16 @@ namespace SqlSugar
|
||||
#region T3
|
||||
public partial class QueryableProvider<T, T2, T3> : QueryableProvider<T>, ISugarQueryable<T, T2, T3>
|
||||
{
|
||||
public new ISugarQueryable<T, T2,T3> SampleBy(int timeNumber, SampleByUnit timeType)
|
||||
{
|
||||
base.SampleBy(timeNumber, timeType);
|
||||
return this;
|
||||
}
|
||||
public new ISugarQueryable<T, T2,T3> SampleBy(int timeNumber, string timeType)
|
||||
{
|
||||
base.SampleBy(timeNumber, timeType);
|
||||
return this;
|
||||
}
|
||||
public virtual ISugarQueryable<TResult> SelectMergeTable<TResult>(Expression<Func<T, T2,T3, TResult>> expression)
|
||||
{
|
||||
return this.Select(expression).MergeTable();
|
||||
@@ -1316,6 +1336,16 @@ namespace SqlSugar
|
||||
#region T4
|
||||
public partial class QueryableProvider<T, T2, T3, T4> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4>
|
||||
{
|
||||
public new ISugarQueryable<T, T2,T3,T4> SampleBy(int timeNumber, SampleByUnit timeType)
|
||||
{
|
||||
base.SampleBy(timeNumber, timeType);
|
||||
return this;
|
||||
}
|
||||
public new ISugarQueryable<T, T2,T3, T4> SampleBy(int timeNumber, string timeType)
|
||||
{
|
||||
base.SampleBy(timeNumber, timeType);
|
||||
return this;
|
||||
}
|
||||
public virtual ISugarQueryable<TResult> SelectMergeTable<TResult>(Expression<Func<T, T2, T3,T4, TResult>> expression)
|
||||
{
|
||||
return this.Select(expression).MergeTable();
|
||||
@@ -2040,6 +2070,16 @@ namespace SqlSugar
|
||||
#region T5
|
||||
public partial class QueryableProvider<T, T2, T3, T4, T5> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5>
|
||||
{
|
||||
public new ISugarQueryable<T, T2,T3, T4,T5> SampleBy(int timeNumber, SampleByUnit timeType)
|
||||
{
|
||||
base.SampleBy(timeNumber, timeType);
|
||||
return this;
|
||||
}
|
||||
public new ISugarQueryable<T, T2,T3, T4,T5> SampleBy(int timeNumber, string timeType)
|
||||
{
|
||||
base.SampleBy(timeNumber, timeType);
|
||||
return this;
|
||||
}
|
||||
public virtual ISugarQueryable<TResult> SelectMergeTable<TResult>(Expression<Func<T, T2, T3, T4, T5, TResult>> expression)
|
||||
{
|
||||
return this.Select(expression).MergeTable();
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace SqlSugar
|
||||
public int ExternalPageSize { get; set; }
|
||||
public int? Take { get; set; }
|
||||
public bool DisableTop { get; set; }
|
||||
public string SampleBy { get; set; }
|
||||
public string OrderByValue { get; set; }
|
||||
public object SelectValue { get; set; }
|
||||
public string SelectCacheKey { get; set; }
|
||||
@@ -138,6 +139,10 @@ namespace SqlSugar
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.SampleBy.HasValue())
|
||||
{
|
||||
return "SELECT {0} FROM {1}{2} "+ this.SampleBy + " {3}{4}";
|
||||
}
|
||||
return "SELECT {0} FROM {1}{2}{3}{4} ";
|
||||
}
|
||||
}
|
||||
|
||||
16
Src/Asp.Net/SqlSugar/Enum/SampleByUnit.cs
Normal file
16
Src/Asp.Net/SqlSugar/Enum/SampleByUnit.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public enum SampleByUnit
|
||||
{
|
||||
Second,
|
||||
Minute,
|
||||
Hour,
|
||||
Day,
|
||||
Month,
|
||||
Year
|
||||
}
|
||||
}
|
||||
@@ -235,7 +235,7 @@ namespace SqlSugar
|
||||
{
|
||||
addItem.DbType = System.Data.DbType.Date;
|
||||
}
|
||||
if (addItem.Value == null && dataType.IsIn(UtilConstants.FloatType, UtilConstants.IntType, UtilConstants.LongType, UtilConstants.DecType, UtilConstants.DobType))
|
||||
if (addItem.Value == null && dataType.IsIn(UtilConstants.ULongType,UtilConstants.UIntType,UtilConstants.FloatType, UtilConstants.IntType, UtilConstants.LongType, UtilConstants.DecType, UtilConstants.DobType))
|
||||
{
|
||||
addItem.DbType = System.Data.DbType.Int32;
|
||||
}
|
||||
|
||||
@@ -109,6 +109,8 @@ namespace SqlSugar
|
||||
ISugarQueryable<T> OrderByDescending(Expression<Func<T, object>> expression);
|
||||
ISugarQueryable<T> OrderByIF(bool isOrderBy, string orderFileds);
|
||||
ISugarQueryable<T> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T> SampleBy(int timeNumber, SampleByUnit timeType);
|
||||
ISugarQueryable<T> SampleBy(int timeNumber, string timeType);
|
||||
|
||||
|
||||
ISugarQueryable<T> GroupBy(Expression<Func<T, object>> expression);
|
||||
@@ -266,6 +268,8 @@ namespace SqlSugar
|
||||
}
|
||||
public partial interface ISugarQueryable<T, T2> : ISugarQueryable<T>
|
||||
{
|
||||
new ISugarQueryable<T,T2> SampleBy(int timeNumber, SampleByUnit timeType);
|
||||
new ISugarQueryable<T,T2> SampleBy(int timeNumber, string timeType);
|
||||
ISugarQueryable<TResult> SelectMergeTable<TResult>(Expression<Func<T,T2, TResult>> expression);
|
||||
ISugarQueryable<T, T2,T3> LeftJoinIF<T3>(bool isLeftJoin, Expression<Func<T, T2,T3, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2,T3> InnerJoinIF<T3>(bool isJoin, Expression<Func<T, T2,T3, bool>> joinExpression);
|
||||
@@ -384,6 +388,8 @@ namespace SqlSugar
|
||||
}
|
||||
public partial interface ISugarQueryable<T, T2, T3> : ISugarQueryable<T>
|
||||
{
|
||||
new ISugarQueryable<T, T2,T3> SampleBy(int timeNumber, SampleByUnit timeType);
|
||||
new ISugarQueryable<T, T2,T3> SampleBy(int timeNumber, string timeType);
|
||||
ISugarQueryable<TResult> SelectMergeTable<TResult>(Expression<Func<T, T2,T3, TResult>> expression);
|
||||
ISugarQueryable<T, T2, T3,T4> LeftJoinIF<T4>(bool isLeftJoin, Expression<Func<T, T2, T3,T4, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3,T4> InnerJoinIF<T4>(bool isJoin, Expression<Func<T, T2, T3,T4, bool>> joinExpression);
|
||||
@@ -517,6 +523,8 @@ namespace SqlSugar
|
||||
}
|
||||
public partial interface ISugarQueryable<T, T2, T3, T4> : ISugarQueryable<T>
|
||||
{
|
||||
new ISugarQueryable<T, T2, T3,T4> SampleBy(int timeNumber, SampleByUnit timeType);
|
||||
new ISugarQueryable<T, T2, T3,T4> SampleBy(int timeNumber, string timeType);
|
||||
ISugarQueryable<TResult> SelectMergeTable<TResult>(Expression<Func<T, T2, T3,T4, TResult>> expression);
|
||||
ISugarQueryable<T, T2, T3, T4,T5> LeftJoinIF<T5>(bool isLeftJoin, Expression<Func<T, T2, T3, T4,T5, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4,T5> InnerJoinIF<T5>(bool isJoin, Expression<Func<T, T2, T3, T4,T5, bool>> joinExpression);
|
||||
@@ -656,6 +664,8 @@ namespace SqlSugar
|
||||
}
|
||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5> : ISugarQueryable<T>
|
||||
{
|
||||
new ISugarQueryable<T, T2, T3, T4,T5> SampleBy(int timeNumber, SampleByUnit timeType);
|
||||
new ISugarQueryable<T, T2, T3, T4,T5> SampleBy(int timeNumber, string timeType);
|
||||
ISugarQueryable<TResult> SelectMergeTable<TResult>(Expression<Func<T, T2, T3,T4,T5, TResult>> expression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5,T6> LeftJoinIF<T6>(bool isLeftJoin, Expression<Func<T, T2, T3, T4, T5,T6, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5,T6> InnerJoinIF<T6>(bool isJoin, Expression<Func<T, T2, T3, T4, T5,T6, bool>> joinExpression);
|
||||
|
||||
@@ -15,6 +15,10 @@ namespace SqlSugar
|
||||
SELECT * FROM TABLE WHERE CONDITION ORDER BY ID DESC LIMIT 0,10
|
||||
*/
|
||||
var template = "SELECT {0} FROM {1} {2} {3} {4} LIMIT {5},{6}";
|
||||
if (this.SampleBy.HasValue())
|
||||
{
|
||||
template = "SELECT {0} FROM {1} {2} "+this.SampleBy+" {3} {4} LIMIT {5},{6}";
|
||||
}
|
||||
return template;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,6 +156,7 @@
|
||||
<Compile Include="Entities\DefaultCustom.cs" />
|
||||
<Compile Include="Entities\DeleteNavOptions.cs" />
|
||||
<Compile Include="Entities\JoinInfoParameter.cs" />
|
||||
<Compile Include="Enum\SampleByUnit.cs" />
|
||||
<Compile Include="ExpressionsToSql\Common\ExpressionContextCase.cs" />
|
||||
<Compile Include="ExpressionsToSql\Common\ParameterExpressionVisitor.cs" />
|
||||
<Compile Include="ExpressionsToSql\Common\ListAnyParameter.cs" />
|
||||
|
||||
Reference in New Issue
Block a user