mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 18:22:23 +08:00
Update Core
This commit is contained in:
@@ -365,6 +365,9 @@ namespace SqlSugar
|
|||||||
var convertString = GetProertypeDefaultValue(item);
|
var convertString = GetProertypeDefaultValue(item);
|
||||||
if (convertString == "DateTime.Now" || convertString == null)
|
if (convertString == "DateTime.Now" || convertString == null)
|
||||||
return convertString;
|
return convertString;
|
||||||
|
if (convertString.ObjToString() == "newid()") {
|
||||||
|
return "Guid.NewGuid()";
|
||||||
|
}
|
||||||
if (item.DataType == "bit")
|
if (item.DataType == "bit")
|
||||||
return (convertString == "1" || convertString.Equals("true",StringComparison.CurrentCultureIgnoreCase)).ToString().ToLower();
|
return (convertString == "1" || convertString.Equals("true",StringComparison.CurrentCultureIgnoreCase)).ToString().ToLower();
|
||||||
string result = this.Context.Ado.DbBind.GetConvertString(item.DataType) + "(\"" + convertString + "\")";
|
string result = this.Context.Ado.DbBind.GetConvertString(item.DataType) + "(\"" + convertString + "\")";
|
||||||
|
@@ -227,6 +227,50 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Expressionable<T, T2, T3, T4, T5, T6> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new()
|
||||||
|
{
|
||||||
|
Expression<Func<T, T2, T3, T4, T5, T6, bool>> _exp = null;
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3, T4, T5, T6> And(Expression<Func<T, T2, T3, T4, T5, T6, bool>> exp)
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = exp;
|
||||||
|
else
|
||||||
|
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3, T4, T5, T6> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6, bool>> exp)
|
||||||
|
{
|
||||||
|
if (isAnd)
|
||||||
|
And(exp);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3, T4, T5, T6> Or(Expression<Func<T, T2, T3, T4, T5, T6, bool>> exp)
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = exp;
|
||||||
|
else
|
||||||
|
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3, T4, T5, T6> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6, bool>> exp)
|
||||||
|
{
|
||||||
|
if (isOr)
|
||||||
|
Or(exp);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Expression<Func<T, T2, T3, T4, T5, T6, bool>> ToExpression()
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = (it, t2, t3, t4, T5, t6) => true;
|
||||||
|
return _exp;
|
||||||
|
}
|
||||||
|
}
|
||||||
public class Expressionable
|
public class Expressionable
|
||||||
{
|
{
|
||||||
public static Expressionable<T> Create<T>() where T : class, new()
|
public static Expressionable<T> Create<T>() where T : class, new()
|
||||||
@@ -249,5 +293,9 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return new Expressionable<T, T2, T3, T4, T5>();
|
return new Expressionable<T, T2, T3, T4, T5>();
|
||||||
}
|
}
|
||||||
|
public static Expressionable<T, T2, T3, T4, T5, T6> Create<T, T2, T3, T4, T5, T6>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new()
|
||||||
|
{
|
||||||
|
return new Expressionable<T, T2, T3, T4, T5, T6>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -727,6 +727,12 @@ namespace SqlSugar
|
|||||||
var result = ToDataTablePage(pageIndex, pageSize);
|
var result = ToDataTablePage(pageIndex, pageSize);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public virtual DataTable ToDataTablePage(int pageIndex, int pageSize, ref int totalNumber,ref int totalPage)
|
||||||
|
{
|
||||||
|
var result = ToDataTablePage(pageIndex, pageSize, ref totalNumber);
|
||||||
|
totalPage = (totalNumber + pageSize - 1) / pageSize;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual List<T> ToList()
|
public virtual List<T> ToList()
|
||||||
{
|
{
|
||||||
@@ -767,6 +773,12 @@ namespace SqlSugar
|
|||||||
totalNumber = count;
|
totalNumber = count;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public virtual List<T> ToPageList(int pageIndex, int pageSize, ref int totalNumber, ref int totalPage)
|
||||||
|
{
|
||||||
|
var result = ToPageList(pageIndex, pageSize, ref totalNumber);
|
||||||
|
totalPage = (totalNumber + pageSize - 1) / pageSize;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual KeyValuePair<string, List<SugarParameter>> ToSql()
|
public virtual KeyValuePair<string, List<SugarParameter>> ToSql()
|
||||||
{
|
{
|
||||||
@@ -778,13 +790,16 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public ISugarQueryable<T> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public ISugarQueryable<T> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
Check.ArgumentNullException(this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService, "Use Cache ConnectionConfig.ConfigureExternalServices.DataInfoCacheService is required ");
|
Check.ArgumentNullException(this.Context.CurrentConnectionConfig.ConfigureExternalServices.DataInfoCacheService, "Use Cache ConnectionConfig.ConfigureExternalServices.DataInfoCacheService is required ");
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISugarQueryable<T> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public ISugarQueryable<T> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (isCache)
|
if (isCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -1631,6 +1646,15 @@ namespace SqlSugar
|
|||||||
asyncQueryableBuilder.HavingInfos = this.QueryBuilder.HavingInfos;
|
asyncQueryableBuilder.HavingInfos = this.QueryBuilder.HavingInfos;
|
||||||
asyncQueryableBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
asyncQueryableBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||||
}
|
}
|
||||||
|
protected int SetCacheTime(int cacheDurationInSeconds)
|
||||||
|
{
|
||||||
|
if (cacheDurationInSeconds == int.MaxValue && this.Context.CurrentConnectionConfig.MoreSettings != null && this.Context.CurrentConnectionConfig.MoreSettings.DefaultCacheDurationInSeconds > 0)
|
||||||
|
{
|
||||||
|
cacheDurationInSeconds = this.Context.CurrentConnectionConfig.MoreSettings.DefaultCacheDurationInSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cacheDurationInSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -1912,12 +1936,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (isCache)
|
if (isCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -2281,12 +2307,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -2708,12 +2736,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -3062,12 +3092,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -3447,12 +3479,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -3863,12 +3897,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -4312,12 +4348,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -4710,12 +4748,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -5119,12 +5159,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -5552,12 +5594,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
@@ -6011,12 +6055,14 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithCache(int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
this.CacheTime = cacheDurationInSeconds;
|
this.CacheTime = cacheDurationInSeconds;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue)
|
||||||
{
|
{
|
||||||
|
cacheDurationInSeconds = SetCacheTime(cacheDurationInSeconds);
|
||||||
if (IsCache)
|
if (IsCache)
|
||||||
{
|
{
|
||||||
this.IsCache = true;
|
this.IsCache = true;
|
||||||
|
@@ -189,7 +189,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var isFirst = whereString == null;
|
var isFirst = whereString == null;
|
||||||
whereString += (isFirst ? null : " AND ");
|
whereString += (isFirst ? null : " AND ");
|
||||||
whereString += Regex.Replace(item,"\\"+this.Builder.SqlTranslationLeft,"T."+ this.Builder.SqlTranslationLeft);
|
whereString += Regex.Replace(item,"\\"+this.Builder.SqlTranslationLeft,"S."+ this.Builder.SqlTranslationLeft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PrimaryKeys.HasValue())
|
if (PrimaryKeys.HasValue())
|
||||||
|
@@ -13,5 +13,6 @@ namespace SqlSugar
|
|||||||
/// Some MYSQL databases do not support NVarchar set true
|
/// Some MYSQL databases do not support NVarchar set true
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool MySqlDisableNarvchar { get; set; }
|
public bool MySqlDisableNarvchar { get; set; }
|
||||||
|
public int DefaultCacheDurationInSeconds { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
@@ -13,4 +14,52 @@ namespace SqlSugar
|
|||||||
public int JoinIndex { get; set; }
|
public int JoinIndex { get; set; }
|
||||||
public string JoinWhere { get; set; }
|
public string JoinWhere { get; set; }
|
||||||
}
|
}
|
||||||
|
public class JoinQueryInfos
|
||||||
|
{
|
||||||
|
private JoinQueryInfos() { }
|
||||||
|
public JoinQueryInfos(JoinType joinType, bool whereExpress)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public JoinQueryInfos(JoinType joinType, bool whereExpress, JoinType joinType2, bool whereExpress2)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public JoinQueryInfos(JoinType joinType, bool whereExpress, JoinType joinType2, bool whereExpress2, JoinType joinType3, bool whereExpress3)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public JoinQueryInfos(JoinType joinType, bool whereExpress, JoinType joinType2, bool whereExpress2, JoinType joinType3, bool whereExpress3, JoinType joinType4, bool whereExpress4)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public JoinQueryInfos(JoinType joinType, bool whereExpress, JoinType joinType2, bool whereExpress2, JoinType joinType3, bool whereExpress3, JoinType joinType4, bool whereExpress4, JoinType joinType5, bool whereExpress5)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public JoinQueryInfos(JoinType joinType, bool whereExpress, JoinType joinType2, bool whereExpress2, JoinType joinType3, bool whereExpress3, JoinType joinType4, bool whereExpress4, JoinType joinType5, bool whereExpress5, JoinType joinType6, bool whereExpress6)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public JoinQueryInfos(JoinType joinType, bool whereExpress, JoinType joinType2, bool whereExpress2, JoinType joinType3, bool whereExpress3, JoinType joinType4, bool whereExpress4, JoinType joinType5, bool whereExpress5, JoinType joinType6, bool whereExpress6, JoinType joinType7, bool whereExpress7)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public JoinQueryInfos(JoinType joinType, bool whereExpress, JoinType joinType2, bool whereExpress2, JoinType joinType3, bool whereExpress3, JoinType joinType4, bool whereExpress4, JoinType joinType5, bool whereExpress5, JoinType joinType6, bool whereExpress6, JoinType joinType7, bool whereExpress7, JoinType joinType8, bool whereExpress8)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public JoinQueryInfos(JoinType joinType, bool whereExpress, JoinType joinType2, bool whereExpress2, JoinType joinType3, bool whereExpress3, JoinType joinType4, bool whereExpress4, JoinType joinType5, bool whereExpress5, JoinType joinType6, bool whereExpress6, JoinType joinType7, bool whereExpress7, JoinType joinType8, bool whereExpress8, JoinType joinType9, bool whereExpress9)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public JoinQueryInfos(JoinType joinType, bool whereExpress, JoinType joinType2, bool whereExpress2, JoinType joinType3, bool whereExpress3, JoinType joinType4, bool whereExpress4, JoinType joinType5, bool whereExpress5, JoinType joinType6, bool whereExpress6, JoinType joinType7, bool whereExpress7, JoinType joinType8, bool whereExpress8, JoinType joinType9, bool whereExpress9, JoinType joinType10, bool whereExpress10)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public JoinQueryInfos(JoinType joinType, bool whereExpress, JoinType joinType2, bool whereExpress2, JoinType joinType3, bool whereExpress3, JoinType joinType4, bool whereExpress4, JoinType joinType5, bool whereExpress5, JoinType joinType6, bool whereExpress6, JoinType joinType7, bool whereExpress7, JoinType joinType8, bool whereExpress8, JoinType joinType9, bool whereExpress9, JoinType joinType10, bool whereExpress10, JoinType joinType11, bool whereExpress11)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -128,6 +128,19 @@ namespace SqlSugar
|
|||||||
set { _IsTranscoding = value; }
|
set { _IsTranscoding = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _NoSerialize;
|
||||||
|
public bool NoSerialize
|
||||||
|
{
|
||||||
|
get { return _NoSerialize; }
|
||||||
|
set { _NoSerialize = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _SerializeDateTimeFormat;
|
||||||
|
public string SerializeDateTimeFormat
|
||||||
|
{
|
||||||
|
get { return _SerializeDateTimeFormat; }
|
||||||
|
set { _SerializeDateTimeFormat = value; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public partial class SugarDateTimeFormat
|
||||||
|
{
|
||||||
|
public const string Default = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
public const string Date = "yyyy-MM-dd HH";
|
||||||
|
}
|
||||||
|
}
|
@@ -255,5 +255,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return !IsEntity(type);
|
return !IsEntity(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsUnConvertExpress(Expression item)
|
||||||
|
{
|
||||||
|
return item is UnaryExpression && item.NodeType == ExpressionType.Convert;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,7 @@ namespace SqlSugar
|
|||||||
public class MethodCallExpressionModel
|
public class MethodCallExpressionModel
|
||||||
{
|
{
|
||||||
public List<MethodCallExpressionArgs> Args { get; set; }
|
public List<MethodCallExpressionArgs> Args { get; set; }
|
||||||
|
public string Name { get; internal set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MethodCallExpressionArgs
|
public class MethodCallExpressionArgs
|
||||||
|
@@ -41,6 +41,35 @@ namespace SqlSugar
|
|||||||
SettingDataType(type);
|
SettingDataType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SugarParameter(string name, object value, System.Data.DbType type)
|
||||||
|
{
|
||||||
|
this.Value = value;
|
||||||
|
this.ParameterName = name;
|
||||||
|
this.DbType = type;
|
||||||
|
}
|
||||||
|
public SugarParameter(string name, DataTable value,string SqlServerTypeName)
|
||||||
|
{
|
||||||
|
this.Value = value;
|
||||||
|
this.ParameterName = name;
|
||||||
|
this.TypeName = SqlServerTypeName;
|
||||||
|
}
|
||||||
|
public SugarParameter(string name, object value, System.Data.DbType type, ParameterDirection direction)
|
||||||
|
{
|
||||||
|
this.Value = value;
|
||||||
|
this.ParameterName = name;
|
||||||
|
this.Direction = direction;
|
||||||
|
this.DbType = type;
|
||||||
|
}
|
||||||
|
public SugarParameter(string name, object value, System.Data.DbType type, ParameterDirection direction, int size)
|
||||||
|
{
|
||||||
|
this.Value = value;
|
||||||
|
this.ParameterName = name;
|
||||||
|
this.Direction = direction;
|
||||||
|
this.Size = size;
|
||||||
|
this.DbType = type;
|
||||||
|
}
|
||||||
|
|
||||||
private void SettingDataType(Type type)
|
private void SettingDataType(Type type)
|
||||||
{
|
{
|
||||||
if (type == UtilConstants.ByteArrayType)
|
if (type == UtilConstants.ByteArrayType)
|
||||||
@@ -197,5 +226,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
this.DbType = System.Data.DbType.String;
|
this.DbType = System.Data.DbType.String;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string TypeName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -400,7 +400,8 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
this.Context.Result.Append(this.Context.GetAsString(asName, newContext.Result.GetString()));
|
this.Context.Result.Append(this.Context.GetAsString(asName, newContext.Result.GetString()));
|
||||||
this.Context.Result.CurrentParameter = null;
|
this.Context.Result.CurrentParameter = null;
|
||||||
if (this.Context.SingleTableNameSubqueryShortName.IsNullOrEmpty() && newContext.SingleTableNameSubqueryShortName.HasValue()) {
|
if (this.Context.SingleTableNameSubqueryShortName.IsNullOrEmpty() && newContext.SingleTableNameSubqueryShortName.HasValue())
|
||||||
|
{
|
||||||
this.Context.SingleTableNameSubqueryShortName = newContext.SingleTableNameSubqueryShortName;
|
this.Context.SingleTableNameSubqueryShortName = newContext.SingleTableNameSubqueryShortName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -427,7 +428,8 @@ namespace SqlSugar
|
|||||||
var propertyName = property.Name;
|
var propertyName = property.Name;
|
||||||
var dbColumnName = propertyName;
|
var dbColumnName = propertyName;
|
||||||
var mappingInfo = this.Context.MappingColumns.FirstOrDefault(it => it.EntityName == item.Type.Name && it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
|
var mappingInfo = this.Context.MappingColumns.FirstOrDefault(it => it.EntityName == item.Type.Name && it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
|
||||||
if (mappingInfo.HasValue()) {
|
if (mappingInfo.HasValue())
|
||||||
|
{
|
||||||
dbColumnName = mappingInfo.DbColumnName;
|
dbColumnName = mappingInfo.DbColumnName;
|
||||||
}
|
}
|
||||||
asName = this.Context.GetTranslationText(item.Type.Name + "." + propertyName);
|
asName = this.Context.GetTranslationText(item.Type.Name + "." + propertyName);
|
||||||
@@ -442,6 +444,29 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (item.Type == UtilConstants.BoolType && item is MethodCallExpression && (item as MethodCallExpression).Method.Name == "Any"&&IsSubMethod(item as MethodCallExpression))
|
||||||
|
{
|
||||||
|
this.Expression = item;
|
||||||
|
this.Start();
|
||||||
|
var sql= this.Context.DbMehtods.IIF(new MethodCallExpressionModel()
|
||||||
|
{
|
||||||
|
Args=new List<MethodCallExpressionArgs>() {
|
||||||
|
new MethodCallExpressionArgs() {
|
||||||
|
IsMember=true,
|
||||||
|
MemberName=parameter.CommonTempData.ObjToString()
|
||||||
|
},
|
||||||
|
new MethodCallExpressionArgs() {
|
||||||
|
IsMember=true,
|
||||||
|
MemberName=1
|
||||||
|
},
|
||||||
|
new MethodCallExpressionArgs() {
|
||||||
|
IsMember=true,
|
||||||
|
MemberName=0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
parameter.Context.Result.Append(this.Context.GetAsString(asName, sql));
|
||||||
|
}
|
||||||
else if (item is MethodCallExpression || item is UnaryExpression || item is ConditionalExpression || item.NodeType == ExpressionType.Coalesce)
|
else if (item is MethodCallExpression || item is UnaryExpression || item is ConditionalExpression || item.NodeType == ExpressionType.Coalesce)
|
||||||
{
|
{
|
||||||
this.Expression = item;
|
this.Expression = item;
|
||||||
@@ -453,6 +478,11 @@ namespace SqlSugar
|
|||||||
Check.ThrowNotSupportedException(item.GetType().Name);
|
Check.ThrowNotSupportedException(item.GetType().Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected bool IsSubMethod(MethodCallExpression express)
|
||||||
|
{
|
||||||
|
return SubTools.SubItemsConst.Any(it => express.Object != null && express.Object.Type.Name == "Subqueryable`1");
|
||||||
|
}
|
||||||
protected static Dictionary<string, string> MethodMapping = new Dictionary<string, string>() {
|
protected static Dictionary<string, string> MethodMapping = new Dictionary<string, string>() {
|
||||||
{ "ToString","ToString"},
|
{ "ToString","ToString"},
|
||||||
{ "ToInt32","ToInt32"},
|
{ "ToInt32","ToInt32"},
|
||||||
|
@@ -172,6 +172,7 @@ namespace SqlSugar
|
|||||||
var method = express.Method;
|
var method = express.Method;
|
||||||
var args = express.Arguments.Cast<Expression>().ToList();
|
var args = express.Arguments.Cast<Expression>().ToList();
|
||||||
MethodCallExpressionModel model = new MethodCallExpressionModel();
|
MethodCallExpressionModel model = new MethodCallExpressionModel();
|
||||||
|
model.Name = name;
|
||||||
model.Args = new List<MethodCallExpressionArgs>();
|
model.Args = new List<MethodCallExpressionArgs>();
|
||||||
switch (this.Context.ResolveType)
|
switch (this.Context.ResolveType)
|
||||||
{
|
{
|
||||||
@@ -297,6 +298,10 @@ namespace SqlSugar
|
|||||||
|
|
||||||
private void AppendItem(ExpressionParameter parameter, string name, IEnumerable<Expression> args, MethodCallExpressionModel model, Expression item)
|
private void AppendItem(ExpressionParameter parameter, string name, IEnumerable<Expression> args, MethodCallExpressionModel model, Expression item)
|
||||||
{
|
{
|
||||||
|
if (ExpressionTool.IsUnConvertExpress(item))
|
||||||
|
{
|
||||||
|
item = (item as UnaryExpression).Operand;
|
||||||
|
}
|
||||||
var isBinaryExpression = item is BinaryExpression || item is MethodCallExpression;
|
var isBinaryExpression = item is BinaryExpression || item is MethodCallExpression;
|
||||||
var isConst = item is ConstantExpression;
|
var isConst = item is ConstantExpression;
|
||||||
var isIIF = name == "IIF";
|
var isIIF = name == "IIF";
|
||||||
@@ -343,6 +348,8 @@ namespace SqlSugar
|
|||||||
AppendModel(parameter, model, item);
|
AppendModel(parameter, model, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void AppendModelByIIFMember(ExpressionParameter parameter, MethodCallExpressionModel model, Expression item)
|
private void AppendModelByIIFMember(ExpressionParameter parameter, MethodCallExpressionModel model, Expression item)
|
||||||
{
|
{
|
||||||
parameter.CommonTempData = CommonTempDataType.Result;
|
parameter.CommonTempData = CommonTempDataType.Result;
|
||||||
@@ -401,7 +408,12 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
parameter.CommonTempData = DateTime.Now.Date;
|
parameter.CommonTempData = DateTime.Now.Date;
|
||||||
}
|
}
|
||||||
else {
|
else if (model.Name == "ToString"&&item is ConstantExpression&&(item as ConstantExpression).Type.IsEnum())
|
||||||
|
{
|
||||||
|
parameter.CommonTempData = item.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
base.Start();
|
base.Start();
|
||||||
}
|
}
|
||||||
var methodCallExpressionArgs = new MethodCallExpressionArgs()
|
var methodCallExpressionArgs = new MethodCallExpressionArgs()
|
||||||
|
@@ -42,6 +42,30 @@ namespace SqlSugar
|
|||||||
base.Start();
|
base.Start();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ResolveExpressType.Join:
|
||||||
|
base.Context.ResolveType = ResolveExpressType.WhereMultiple;
|
||||||
|
int i = 0;
|
||||||
|
foreach (var item in expression.Arguments)
|
||||||
|
{
|
||||||
|
if (item.Type!=typeof(JoinType))
|
||||||
|
{
|
||||||
|
base.Expression = item;
|
||||||
|
base.Start();
|
||||||
|
}
|
||||||
|
if (item.Type == typeof(JoinType))
|
||||||
|
{
|
||||||
|
if (i > 0)
|
||||||
|
{
|
||||||
|
base.Context.Result.Append("," + item.ToString()+ ",");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base.Context.Result.Append(item.ToString() + ",");
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -40,7 +40,12 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var exp = expression as MethodCallExpression;
|
var exp = expression as MethodCallExpression;
|
||||||
var argExp = exp.Arguments[0];
|
var argExp = exp.Arguments[0];
|
||||||
var result = "GROUP BY " + SubTools.GetMethodValue(this.Context, argExp, ResolveExpressType.FieldSingle);
|
var type = ResolveExpressType.FieldSingle;
|
||||||
|
if ((argExp as LambdaExpression).Body is NewExpression) {
|
||||||
|
type = ResolveExpressType.ArraySingle;
|
||||||
|
}
|
||||||
|
var result = "GROUP BY " + SubTools.GetMethodValue(this.Context, argExp,type);
|
||||||
|
result = result.TrimEnd(',');
|
||||||
var selfParameterName = this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
|
var selfParameterName = this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
|
||||||
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
|
result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
|
||||||
return result;
|
return result;
|
||||||
|
@@ -39,7 +39,10 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else if (context.Expression is MethodCallExpression)
|
else if (context.Expression is MethodCallExpression)
|
||||||
{
|
{
|
||||||
var meExp = ((context.Expression as MethodCallExpression).Object as MethodCallExpression).Arguments[0] as LambdaExpression;
|
var expArgs = ((context.Expression as MethodCallExpression).Object as MethodCallExpression).Arguments;
|
||||||
|
if (expArgs != null && expArgs.Any())
|
||||||
|
{
|
||||||
|
var meExp = expArgs[0] as LambdaExpression;
|
||||||
var selfParameterName = meExp.Parameters.First().Name;
|
var selfParameterName = meExp.Parameters.First().Name;
|
||||||
context.SingleTableNameSubqueryShortName = (((meExp.Body as BinaryExpression).Left as MemberExpression).Expression as ParameterExpression).Name;
|
context.SingleTableNameSubqueryShortName = (((meExp.Body as BinaryExpression).Left as MemberExpression).Expression as ParameterExpression).Name;
|
||||||
if (context.SingleTableNameSubqueryShortName == selfParameterName)
|
if (context.SingleTableNameSubqueryShortName == selfParameterName)
|
||||||
@@ -47,6 +50,7 @@ namespace SqlSugar
|
|||||||
context.SingleTableNameSubqueryShortName = (((meExp.Body as BinaryExpression).Right as MemberExpression).Expression as ParameterExpression).Name;
|
context.SingleTableNameSubqueryShortName = (((meExp.Body as BinaryExpression).Right as MemberExpression).Expression as ParameterExpression).Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (context.Expression.GetType().Name == "MethodBinaryExpression")
|
else if (context.Expression.GetType().Name == "MethodBinaryExpression")
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Converters;
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -10,13 +12,59 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public string SerializeObject(object value)
|
public string SerializeObject(object value)
|
||||||
{
|
{
|
||||||
return JsonConvert.SerializeObject(value);
|
return JsonConvert.SerializeObject(value, new JsonSerializerSettings()
|
||||||
|
{
|
||||||
|
ContractResolver = new MyContractResolver()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public T DeserializeObject<T>(string value)
|
public T DeserializeObject<T>(string value)
|
||||||
{
|
{
|
||||||
var jSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
var jSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, ContractResolver = new MyContractResolver() };
|
||||||
return JsonConvert.DeserializeObject<T>(value, jSetting);
|
return JsonConvert.DeserializeObject<T>(value, jSetting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public class MyContractResolver : Newtonsoft.Json.Serialization.DefaultContractResolver
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public MyContractResolver()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
|
||||||
|
{
|
||||||
|
var list = type.GetProperties()
|
||||||
|
.Where(x => !x.GetCustomAttributes(true).Any(a => (a is SugarColumn) && ((SugarColumn)a).NoSerialize == true))
|
||||||
|
.Select(p => new JsonProperty()
|
||||||
|
{
|
||||||
|
PropertyName = p.Name,
|
||||||
|
PropertyType = p.PropertyType,
|
||||||
|
Readable = true,
|
||||||
|
Writable = true,
|
||||||
|
ValueProvider = base.CreateMemberValueProvider(p)
|
||||||
|
}).ToList();
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
if (UtilMethods.GetUnderType(item.PropertyType) == UtilConstants.DateType)
|
||||||
|
{
|
||||||
|
CreateDateProperty(type, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CreateDateProperty(Type type, JsonProperty item)
|
||||||
|
{
|
||||||
|
var property = type.GetProperties().Where(it => it.Name == item.PropertyName).First();
|
||||||
|
var itemType = UtilMethods.GetUnderType(property);
|
||||||
|
if (property.GetCustomAttributes(true).Any(it => it is SugarColumn))
|
||||||
|
{
|
||||||
|
var sugarAttribute = (SugarColumn)property.GetCustomAttributes(true).First(it => it is SugarColumn);
|
||||||
|
item.Converter = new IsoDateTimeConverter() { DateTimeFormat = sugarAttribute.SerializeDateTimeFormat };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -136,11 +136,13 @@ namespace SqlSugar
|
|||||||
DataTable ToDataTablePage(int pageIndex, int pageSize);
|
DataTable ToDataTablePage(int pageIndex, int pageSize);
|
||||||
Task<DataTable> ToDataTablePageAsync(int pageIndex, int pageSize);
|
Task<DataTable> ToDataTablePageAsync(int pageIndex, int pageSize);
|
||||||
DataTable ToDataTablePage(int pageIndex, int pageSize, ref int totalNumber);
|
DataTable ToDataTablePage(int pageIndex, int pageSize, ref int totalNumber);
|
||||||
|
DataTable ToDataTablePage(int pageIndex, int pageSize, ref int totalNumber,ref int totalPage);
|
||||||
Task<KeyValuePair<DataTable, int>> ToDataTablePageAsync(int pageIndex, int pageSize, int totalNumber);
|
Task<KeyValuePair<DataTable, int>> ToDataTablePageAsync(int pageIndex, int pageSize, int totalNumber);
|
||||||
|
|
||||||
List<T> ToPageList(int pageIndex, int pageSize);
|
List<T> ToPageList(int pageIndex, int pageSize);
|
||||||
Task<List<T>> ToPageListAsync(int pageIndex, int pageSize);
|
Task<List<T>> ToPageListAsync(int pageIndex, int pageSize);
|
||||||
List<T> ToPageList(int pageIndex, int pageSize, ref int totalNumber);
|
List<T> ToPageList(int pageIndex, int pageSize, ref int totalNumber);
|
||||||
|
List<T> ToPageList(int pageIndex, int pageSize, ref int totalNumber,ref int totalPage);
|
||||||
Task<KeyValuePair<List<T>, int>> ToPageListAsync(int pageIndex, int pageSize, int totalNumber);
|
Task<KeyValuePair<List<T>, int>> ToPageListAsync(int pageIndex, int pageSize, int totalNumber);
|
||||||
ISugarQueryable<T> WithCache(int cacheDurationInSeconds = int.MaxValue);
|
ISugarQueryable<T> WithCache(int cacheDurationInSeconds = int.MaxValue);
|
||||||
ISugarQueryable<T> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue);
|
ISugarQueryable<T> WithCacheIF(bool isCache, int cacheDurationInSeconds = int.MaxValue);
|
||||||
|
@@ -0,0 +1,123 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Dynamic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public interface ISqlSugarClient
|
||||||
|
{
|
||||||
|
IAdo Ado { get; }
|
||||||
|
AopProvider Aop { get; }
|
||||||
|
ICodeFirst CodeFirst { get; }
|
||||||
|
SqlSugarClient Context { get; set; }
|
||||||
|
Guid ContextID { get; set; }
|
||||||
|
ConnectionConfig CurrentConnectionConfig { get; set; }
|
||||||
|
IDbFirst DbFirst { get; }
|
||||||
|
IDbMaintenance DbMaintenance { get; }
|
||||||
|
EntityMaintenance EntityMaintenance { get; set; }
|
||||||
|
EntityMaintenance EntityProvider { get; set; }
|
||||||
|
bool IsSystemTablesConfig { get; }
|
||||||
|
QueryFilterProvider QueryFilter { get; set; }
|
||||||
|
IContextMethods RewritableMethods { get; set; }
|
||||||
|
SimpleClient SimpleClient { get; }
|
||||||
|
Dictionary<string, object> TempItems { get; set; }
|
||||||
|
IContextMethods Utilities { get; set; }
|
||||||
|
|
||||||
|
void AddQueue(string sql, SugarParameter parsmeter);
|
||||||
|
void AddQueue(string sql, List<SugarParameter> parsmeters);
|
||||||
|
void AddQueue(string sql, object parsmeters = null);
|
||||||
|
void Close();
|
||||||
|
IDeleteable<T> Deleteable<T>() where T : class, new();
|
||||||
|
IDeleteable<T> Deleteable<T>(T deleteObj) where T : class, new();
|
||||||
|
IDeleteable<T> Deleteable<T>(List<dynamic> pkValue) where T : class, new();
|
||||||
|
IDeleteable<T> Deleteable<T>(List<T> deleteObjs) where T : class, new();
|
||||||
|
IDeleteable<T> Deleteable<T>(Expression<Func<T, bool>> expression) where T : class, new();
|
||||||
|
IDeleteable<T> Deleteable<T>(dynamic[] primaryKeyValues) where T : class, new();
|
||||||
|
IDeleteable<T> Deleteable<T>(dynamic primaryKeyValue) where T : class, new();
|
||||||
|
void Dispose();
|
||||||
|
DateTime GetDate();
|
||||||
|
SimpleClient GetSimpleClient();
|
||||||
|
SimpleClient<T> GetSimpleClient<T>() where T : class, new();
|
||||||
|
void InitMppingInfo(Type type);
|
||||||
|
IInsertable<T> Insertable<T>(T[] insertObjs) where T : class, new();
|
||||||
|
IInsertable<T> Insertable<T>(List<T> insertObjs) where T : class, new();
|
||||||
|
IInsertable<T> Insertable<T>(T insertObj) where T : class, new();
|
||||||
|
IInsertable<T> Insertable<T>(dynamic insertDynamicObject) where T : class, new();
|
||||||
|
IInsertable<T> Insertable<T>(Dictionary<string, object> columnDictionary) where T : class, new();
|
||||||
|
void Open();
|
||||||
|
ISugarQueryable<ExpandoObject> Queryable(string tableName, string shortName);
|
||||||
|
ISugarQueryable<T> Queryable<T>();
|
||||||
|
ISugarQueryable<T> Queryable<T>(string shortName);
|
||||||
|
ISugarQueryable<T> Queryable<T>(ISugarQueryable<T> queryable) where T : class, new();
|
||||||
|
ISugarQueryable<T, T2> Queryable<T, T2>(Expression<Func<T, T2, object[]>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2> Queryable<T, T2>(Expression<Func<T, T2, JoinQueryInfos>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2> Queryable<T, T2>(Expression<Func<T, T2, bool>> joinExpression) where T : class, new();
|
||||||
|
ISugarQueryable<T, T2> Queryable<T, T2>(ISugarQueryable<T> joinQueryable1, ISugarQueryable<T2> joinQueryable2, Expression<Func<T, T2, bool>> joinExpression)
|
||||||
|
where T : class, new()
|
||||||
|
where T2 : class, new();
|
||||||
|
ISugarQueryable<T, T2> Queryable<T, T2>(ISugarQueryable<T> joinQueryable1, ISugarQueryable<T2> joinQueryable2, JoinType joinType, Expression<Func<T, T2, bool>> joinExpression)
|
||||||
|
where T : class, new()
|
||||||
|
where T2 : class, new();
|
||||||
|
ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3, JoinQueryInfos>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3, bool>> joinExpression) where T : class, new();
|
||||||
|
ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(Expression<Func<T, T2, T3, T4, object[]>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(Expression<Func<T, T2, T3, T4, JoinQueryInfos>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(Expression<Func<T, T2, T3, T4, bool>> joinExpression) where T : class, new();
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5> Queryable<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, T5, JoinQueryInfos>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5> Queryable<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5> Queryable<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, T5, bool>> joinExpression) where T : class, new();
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6> Queryable<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, T6, object[]>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6> Queryable<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, T6, JoinQueryInfos>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6> Queryable<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, T6, bool>> joinExpression) where T : class, new();
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Queryable<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, T7, object[]>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Queryable<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, T7, JoinQueryInfos>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Queryable<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> joinExpression) where T : class, new();
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Queryable<T, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, JoinQueryInfos>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Queryable<T, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object[]>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Queryable<T, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> joinExpression) where T : class, new();
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object[]>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, JoinQueryInfos>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> joinExpression) where T : class, new();
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object[]>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, JoinQueryInfos>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> joinExpression) where T : class, new();
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object[]>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, JoinQueryInfos>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> joinExpression) where T : class, new();
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, object[]>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, JoinQueryInfos>> joinExpression);
|
||||||
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> joinExpression) where T : class, new();
|
||||||
|
ISaveable<T> Saveable<T>(T saveObject) where T : class, new();
|
||||||
|
ISaveable<T> Saveable<T>(List<T> saveObjects) where T : class, new();
|
||||||
|
int SaveQueues(bool isTran = true);
|
||||||
|
List<T> SaveQueues<T>(bool isTran = true);
|
||||||
|
Tuple<List<T>, List<T2>> SaveQueues<T, T2>(bool isTran = true);
|
||||||
|
Tuple<List<T>, List<T2>, List<T3>> SaveQueues<T, T2, T3>(bool isTran = true);
|
||||||
|
Tuple<List<T>, List<T2>, List<T3>, List<T4>> SaveQueues<T, T2, T3, T4>(bool isTran = true);
|
||||||
|
Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>> SaveQueues<T, T2, T3, T4, T5>(bool isTran = true);
|
||||||
|
Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>, List<T6>> SaveQueues<T, T2, T3, T4, T5, T6>(bool isTran = true);
|
||||||
|
Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>, List<T6>, List<T7>> SaveQueues<T, T2, T3, T4, T5, T6, T7>(bool isTran = true);
|
||||||
|
Task<int> SaveQueuesAsync(bool isTran = true);
|
||||||
|
Task<List<T>> SaveQueuesAsync<T>(bool isTran = true);
|
||||||
|
Task<Tuple<List<T>, List<T2>>> SaveQueuesAsync<T, T2>(bool isTran = true);
|
||||||
|
Task<Tuple<List<T>, List<T2>, List<T3>>> SaveQueuesAsync<T, T2, T3>(bool isTran = true);
|
||||||
|
Task<Tuple<List<T>, List<T2>, List<T3>, List<T4>>> SaveQueuesAsync<T, T2, T3, T4>(bool isTran = true);
|
||||||
|
Task<Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>>> SaveQueuesAsync<T, T2, T3, T4, T5>(bool isTran = true);
|
||||||
|
Task<Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>, List<T6>>> SaveQueuesAsync<T, T2, T3, T4, T5, T6>(bool isTran = true);
|
||||||
|
Task<Tuple<List<T>, List<T2>, List<T3>, List<T4>, List<T5>, List<T6>, List<T7>>> SaveQueuesAsync<T, T2, T3, T4, T5, T6, T7>(bool isTran = true);
|
||||||
|
ISugarQueryable<T> SqlQueryable<T>(string sql) where T : class, new();
|
||||||
|
ISugarQueryable<T> Union<T>(params ISugarQueryable<T>[] queryables) where T : class, new();
|
||||||
|
ISugarQueryable<T> Union<T>(List<ISugarQueryable<T>> queryables) where T : class, new();
|
||||||
|
ISugarQueryable<T> UnionAll<T>(params ISugarQueryable<T>[] queryables) where T : class, new();
|
||||||
|
ISugarQueryable<T> UnionAll<T>(List<ISugarQueryable<T>> queryables) where T : class, new();
|
||||||
|
IUpdateable<T> Updateable<T>() where T : class, new();
|
||||||
|
IUpdateable<T> Updateable<T>(T[] UpdateObjs) where T : class, new();
|
||||||
|
IUpdateable<T> Updateable<T>(List<T> UpdateObjs) where T : class, new();
|
||||||
|
IUpdateable<T> Updateable<T>(T UpdateObj) where T : class, new();
|
||||||
|
IUpdateable<T> Updateable<T>(dynamic updateDynamicObject) where T : class, new();
|
||||||
|
IUpdateable<T> Updateable<T>(Dictionary<string, object> columnDictionary) where T : class, new();
|
||||||
|
}
|
||||||
|
}
|
@@ -71,7 +71,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var isFirst = whereString == null;
|
var isFirst = whereString == null;
|
||||||
whereString += (isFirst ? null : " AND ");
|
whereString += (isFirst ? null : " AND ");
|
||||||
whereString += Regex.Replace(item, " \\" + this.Builder.SqlTranslationLeft, "T." + this.Builder.SqlTranslationLeft);
|
whereString += Regex.Replace(item, " \\" + this.Builder.SqlTranslationLeft, "S." + this.Builder.SqlTranslationLeft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PrimaryKeys.HasValue())
|
if (PrimaryKeys.HasValue())
|
||||||
|
@@ -26,8 +26,11 @@ namespace SqlSugar
|
|||||||
PreToSql();
|
PreToSql();
|
||||||
string sql = InsertBuilder.ToSqlString();
|
string sql = InsertBuilder.ToSqlString();
|
||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
|
var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation;
|
||||||
|
this.Context.Ado.IsDisableMasterSlaveSeparation = true;
|
||||||
var count = Ado.ExecuteCommand(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
|
var count = Ado.ExecuteCommand(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
|
||||||
var result = (this.GetIdentityKeys().IsNullOrEmpty() || count == 0) ? 0 : GetSeqValue(GetSeqName()).ObjToInt();
|
var result = (this.GetIdentityKeys().IsNullOrEmpty() || count == 0) ? 0 : GetSeqValue(GetSeqName()).ObjToInt();
|
||||||
|
this.Context.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,8 +40,11 @@ namespace SqlSugar
|
|||||||
PreToSql();
|
PreToSql();
|
||||||
string sql = InsertBuilder.ToSqlString();
|
string sql = InsertBuilder.ToSqlString();
|
||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
|
var isDisableMasterSlaveSeparation = this.Context.Ado.IsDisableMasterSlaveSeparation;
|
||||||
|
this.Context.Ado.IsDisableMasterSlaveSeparation = true;
|
||||||
var count = Ado.ExecuteCommand(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
|
var count = Ado.ExecuteCommand(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
|
||||||
var result = (this.GetIdentityKeys().IsNullOrEmpty() || count == 0) ? 0 :Convert.ToInt64(GetSeqValue(GetSeqName()));
|
var result = (this.GetIdentityKeys().IsNullOrEmpty() || count == 0) ? 0 :Convert.ToInt64(GetSeqValue(GetSeqName()));
|
||||||
|
this.Context.Ado.IsDisableMasterSlaveSeparation = isDisableMasterSlaveSeparation;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -66,8 +66,8 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
if (parameters.HasValue())
|
if (parameters.HasValue())
|
||||||
{
|
{
|
||||||
IDataParameter[] ipars = ToIDbDataParameter(parameters);
|
SqlParameter[] ipars = GetSqlParameter(parameters);
|
||||||
sqlCommand.Parameters.AddRange((SqlParameter[])ipars);
|
sqlCommand.Parameters.AddRange(ipars);
|
||||||
}
|
}
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
return sqlCommand;
|
return sqlCommand;
|
||||||
@@ -108,5 +108,42 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// if mysql return MySqlParameter[] pars
|
||||||
|
/// if sqlerver return SqlParameter[] pars ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parameters"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public SqlParameter[] GetSqlParameter(params SugarParameter[] parameters)
|
||||||
|
{
|
||||||
|
if (parameters == null || parameters.Length == 0) return null;
|
||||||
|
SqlParameter[] result = new SqlParameter[parameters.Length];
|
||||||
|
int index = 0;
|
||||||
|
foreach (var parameter in parameters)
|
||||||
|
{
|
||||||
|
if (parameter.Value == null) parameter.Value = DBNull.Value;
|
||||||
|
var sqlParameter = new SqlParameter();
|
||||||
|
sqlParameter.ParameterName = parameter.ParameterName;
|
||||||
|
//sqlParameter.UdtTypeName = parameter.UdtTypeName;
|
||||||
|
sqlParameter.Size = parameter.Size;
|
||||||
|
sqlParameter.Value = parameter.Value;
|
||||||
|
sqlParameter.DbType = parameter.DbType;
|
||||||
|
sqlParameter.Direction = parameter.Direction;
|
||||||
|
result[index] = sqlParameter;
|
||||||
|
if (parameter.TypeName.HasValue()) {
|
||||||
|
sqlParameter.TypeName = parameter.TypeName;
|
||||||
|
sqlParameter.SqlDbType = SqlDbType.Structured;
|
||||||
|
sqlParameter.DbType = System.Data.DbType.Object;
|
||||||
|
}
|
||||||
|
if (sqlParameter.Direction.IsIn(ParameterDirection.Output, ParameterDirection.InputOutput, ParameterDirection.ReturnValue))
|
||||||
|
{
|
||||||
|
if (this.OutputParameters == null) this.OutputParameters = new List<IDataParameter>();
|
||||||
|
this.OutputParameters.RemoveAll(it => it.ParameterName == sqlParameter.ParameterName);
|
||||||
|
this.OutputParameters.Add(sqlParameter);
|
||||||
|
}
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@ namespace SqlSugar
|
|||||||
/// ** date:2017/1/2
|
/// ** date:2017/1/2
|
||||||
/// ** email:610262374@qq.com
|
/// ** email:610262374@qq.com
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class SqlSugarClient : IDisposable
|
public partial class SqlSugarClient : IDisposable, ISqlSugarClient
|
||||||
{
|
{
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
@@ -141,6 +141,14 @@ namespace SqlSugar
|
|||||||
this.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
|
public virtual ISugarQueryable<T, T2> Queryable<T, T2>(Expression<Func<T, T2, JoinQueryInfos>> joinExpression)
|
||||||
|
{
|
||||||
|
InitMppingInfo<T, T2>();
|
||||||
|
var types = new Type[] { typeof(T2) };
|
||||||
|
var queryable = InstanceFactory.GetQueryable<T, T2>(this.CurrentConnectionConfig);
|
||||||
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
|
return queryable;
|
||||||
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression)
|
public virtual ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3, object[]>> joinExpression)
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3>();
|
InitMppingInfo<T, T2, T3>();
|
||||||
@@ -149,6 +157,14 @@ namespace SqlSugar
|
|||||||
this.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
|
public virtual ISugarQueryable<T, T2, T3> Queryable<T, T2, T3>(Expression<Func<T, T2, T3,JoinQueryInfos>> joinExpression)
|
||||||
|
{
|
||||||
|
InitMppingInfo<T, T2, T3>();
|
||||||
|
var types = new Type[] { typeof(T2), typeof(T3) };
|
||||||
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3>(this.CurrentConnectionConfig);
|
||||||
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
|
return queryable;
|
||||||
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(Expression<Func<T, T2, T3, T4, object[]>> joinExpression)
|
public virtual ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(Expression<Func<T, T2, T3, T4, object[]>> joinExpression)
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4>();
|
InitMppingInfo<T, T2, T3, T4>();
|
||||||
@@ -157,6 +173,14 @@ namespace SqlSugar
|
|||||||
this.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
|
public virtual ISugarQueryable<T, T2, T3, T4> Queryable<T, T2, T3, T4>(Expression<Func<T, T2, T3, T4,JoinQueryInfos>> joinExpression)
|
||||||
|
{
|
||||||
|
InitMppingInfo<T, T2, T3, T4>();
|
||||||
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4) };
|
||||||
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4>(this.CurrentConnectionConfig);
|
||||||
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
|
return queryable;
|
||||||
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5> Queryable<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression)
|
public virtual ISugarQueryable<T, T2, T3, T4, T5> Queryable<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression)
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5>();
|
InitMppingInfo<T, T2, T3, T4, T5>();
|
||||||
@@ -165,6 +189,14 @@ namespace SqlSugar
|
|||||||
this.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
|
public virtual ISugarQueryable<T, T2, T3, T4, T5> Queryable<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, T5,JoinQueryInfos>> joinExpression)
|
||||||
|
{
|
||||||
|
InitMppingInfo<T, T2, T3, T4, T5>();
|
||||||
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5) };
|
||||||
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5>(this.CurrentConnectionConfig);
|
||||||
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
|
return queryable;
|
||||||
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6> Queryable<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, T6, object[]>> joinExpression)
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6> Queryable<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, T6, object[]>> joinExpression)
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6>();
|
||||||
@@ -173,6 +205,14 @@ namespace SqlSugar
|
|||||||
this.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6> Queryable<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, T6, JoinQueryInfos>> joinExpression)
|
||||||
|
{
|
||||||
|
InitMppingInfo<T, T2, T3, T4, T5, T6>();
|
||||||
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6) };
|
||||||
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6>(this.CurrentConnectionConfig);
|
||||||
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
|
return queryable;
|
||||||
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Queryable<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, T7, object[]>> joinExpression)
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Queryable<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, T7, object[]>> joinExpression)
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T7>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7>();
|
||||||
@@ -181,6 +221,14 @@ namespace SqlSugar
|
|||||||
this.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Queryable<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, T7, JoinQueryInfos>> joinExpression)
|
||||||
|
{
|
||||||
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7>();
|
||||||
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7) };
|
||||||
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7>(this.CurrentConnectionConfig);
|
||||||
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
|
return queryable;
|
||||||
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Queryable<T, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object[]>> joinExpression)
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Queryable<T, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object[]>> joinExpression)
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8>();
|
||||||
@@ -189,6 +237,14 @@ namespace SqlSugar
|
|||||||
this.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Queryable<T, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, JoinQueryInfos>> joinExpression)
|
||||||
|
{
|
||||||
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8>();
|
||||||
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8) };
|
||||||
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(this.CurrentConnectionConfig);
|
||||||
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
|
return queryable;
|
||||||
|
}
|
||||||
#region 9-12
|
#region 9-12
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object[]>> joinExpression)
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object[]>> joinExpression)
|
||||||
{
|
{
|
||||||
@@ -198,6 +254,14 @@ namespace SqlSugar
|
|||||||
this.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, JoinQueryInfos>> joinExpression)
|
||||||
|
{
|
||||||
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9>();
|
||||||
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9) };
|
||||||
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(this.CurrentConnectionConfig);
|
||||||
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
|
return queryable;
|
||||||
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object[]>> joinExpression)
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object[]>> joinExpression)
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>();
|
||||||
@@ -206,6 +270,14 @@ namespace SqlSugar
|
|||||||
this.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, JoinQueryInfos>> joinExpression)
|
||||||
|
{
|
||||||
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>();
|
||||||
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10) };
|
||||||
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this.CurrentConnectionConfig);
|
||||||
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
|
return queryable;
|
||||||
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object[]>> joinExpression)
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object[]>> joinExpression)
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>();
|
||||||
@@ -214,6 +286,14 @@ namespace SqlSugar
|
|||||||
this.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,JoinQueryInfos>> joinExpression)
|
||||||
|
{
|
||||||
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>();
|
||||||
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11) };
|
||||||
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this.CurrentConnectionConfig);
|
||||||
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
|
return queryable;
|
||||||
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, object[]>> joinExpression)
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, object[]>> joinExpression)
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>();
|
||||||
@@ -222,6 +302,14 @@ namespace SqlSugar
|
|||||||
this.CreateQueryJoin(joinExpression, types, queryable);
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, JoinQueryInfos>> joinExpression)
|
||||||
|
{
|
||||||
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>();
|
||||||
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11), typeof(T12) };
|
||||||
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this.CurrentConnectionConfig);
|
||||||
|
this.CreateQueryJoin(joinExpression, types, queryable);
|
||||||
|
return queryable;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
public virtual ISugarQueryable<T, T2> Queryable<T, T2>(Expression<Func<T, T2, bool>> joinExpression) where T : class, new()
|
public virtual ISugarQueryable<T, T2> Queryable<T, T2>(Expression<Func<T, T2, bool>> joinExpression) where T : class, new()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user