mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Update Core
This commit is contained in:
parent
f423102739
commit
c6456076cd
@ -25,13 +25,13 @@ namespace OrmTest
|
||||
}
|
||||
}
|
||||
});
|
||||
public static SqlSugarClient ssDb => new SqlSugarClient(new ConnectionConfig()
|
||||
public static SqlSugarScope ssDb => new SqlSugarScope(new ConnectionConfig()
|
||||
{
|
||||
DbType = DbType.SqlServer,
|
||||
ConnectionString = Config.ConnectionString,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
IsAutoCloseConnection = true,
|
||||
IsShardSameThread = true,
|
||||
//IsShardSameThread = true,
|
||||
AopEvents = new AopEvents
|
||||
{
|
||||
OnLogExecuting = (sql, p) =>
|
||||
|
@ -1274,25 +1274,25 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual void ExecuteBefore(string sql, SugarParameter[] parameters)
|
||||
{
|
||||
if (this.Context.CurrentConnectionConfig.Debugger != null && this.Context.CurrentConnectionConfig.Debugger.EnableThreadSecurityValidation == true)
|
||||
{
|
||||
//if (this.Context.CurrentConnectionConfig.Debugger != null && this.Context.CurrentConnectionConfig.Debugger.EnableThreadSecurityValidation == true)
|
||||
//{
|
||||
|
||||
var contextId = this.Context.ContextID.ToString();
|
||||
var processId = Thread.CurrentThread.ManagedThreadId.ToString();
|
||||
var cache = new ReflectionInoCacheService();
|
||||
if (!cache.ContainsKey<string>(contextId))
|
||||
{
|
||||
cache.Add(contextId, processId);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cacheValue = cache.Get<string>(contextId);
|
||||
if (processId != cacheValue)
|
||||
{
|
||||
throw new SqlSugarException(this.Context, ErrorMessage.GetThrowMessage("Detection of SqlSugarClient cross-threading usage,a thread needs a new one", "检测到声名的SqlSugarClient跨线程使用,请检查是否静态、是否单例、或者IOC配置错误引起的,保证一个线程new出一个对象 ,具本Sql:") + sql, parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
// var contextId = this.Context.ContextID.ToString();
|
||||
// var processId = Thread.CurrentThread.ManagedThreadId.ToString();
|
||||
// var cache = new ReflectionInoCacheService();
|
||||
// if (!cache.ContainsKey<string>(contextId))
|
||||
// {
|
||||
// cache.Add(contextId, processId);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var cacheValue = cache.Get<string>(contextId);
|
||||
// if (processId != cacheValue)
|
||||
// {
|
||||
// throw new SqlSugarException(this.Context, ErrorMessage.GetThrowMessage("Detection of SqlSugarClient cross-threading usage,a thread needs a new one", "检测到声名的SqlSugarClient跨线程使用,请检查是否静态、是否单例、或者IOC配置错误引起的,保证一个线程new出一个对象 ,具本Sql:") + sql, parameters);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
this.BeforeTime = DateTime.Now;
|
||||
if (this.IsEnableLogEvent)
|
||||
{
|
||||
|
@ -24,6 +24,13 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
public SplitCodeFirstProvider SplitTables()
|
||||
{
|
||||
var result = new SplitCodeFirstProvider();
|
||||
result.Context = this.Context;
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual ICodeFirst BackupTable(int maxBackupDataRows = int.MaxValue)
|
||||
{
|
||||
this.IsBackupTable = true;
|
||||
@ -40,8 +47,8 @@ namespace SqlSugar
|
||||
public virtual void InitTables(Type entityType)
|
||||
{
|
||||
|
||||
this.Context.Utilities.RemoveCacheAll();
|
||||
this.Context.InitMappingInfo(entityType);
|
||||
//this.Context.Utilities.RemoveCacheAll();
|
||||
this.Context.InitMappingInfoNoCache(entityType);
|
||||
if (!this.Context.DbMaintenance.IsAnySystemTablePermissions())
|
||||
{
|
||||
Check.Exception(true, "Dbfirst and Codefirst requires system table permissions");
|
||||
@ -107,7 +114,7 @@ namespace SqlSugar
|
||||
#region Core Logic
|
||||
protected virtual void Execute(Type entityType)
|
||||
{
|
||||
var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(entityType);
|
||||
var entityInfo = this.Context.EntityMaintenance.GetEntityInfoNoCache(entityType);
|
||||
if (this.DefultLength > 0)
|
||||
{
|
||||
foreach (var item in entityInfo.Columns)
|
||||
@ -132,7 +139,7 @@ namespace SqlSugar
|
||||
this.Context.MappingTables.Add(entityInfo.EntityName,tableName);
|
||||
entityInfo.DbTableName = tableName;
|
||||
entityInfo.Columns.ForEach(it => { it.DbTableName = tableName; });
|
||||
var isAny = this.Context.DbMaintenance.IsAnyTable(tableName);
|
||||
var isAny = this.Context.DbMaintenance.IsAnyTable(tableName,false);
|
||||
if (isAny&&entityInfo.IsDisabledUpdateAll)
|
||||
{
|
||||
return;
|
||||
@ -168,7 +175,7 @@ namespace SqlSugar
|
||||
//Check.Exception(entityInfo.Columns.Where(it => it.IsPrimarykey).Count() > 1, "Multiple primary keys do not support modifications");
|
||||
|
||||
var tableName = GetTableName(entityInfo);
|
||||
var dbColumns = this.Context.DbMaintenance.GetColumnInfosByTableName(tableName);
|
||||
var dbColumns = this.Context.DbMaintenance.GetColumnInfosByTableName(tableName,false);
|
||||
ConvertColumns(dbColumns);
|
||||
var entityColumns = entityInfo.Columns.Where(it => it.IsIgnore == false).ToList();
|
||||
var dropColumns = dbColumns
|
||||
|
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class SplitCodeFirstProvider
|
||||
{
|
||||
public SqlSugarProvider Context;
|
||||
public void InitTables<T>()
|
||||
{
|
||||
var type = typeof(T);
|
||||
InitTables(type);
|
||||
}
|
||||
|
||||
public void InitTables(Type type)
|
||||
{
|
||||
//var oldMapping = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
|
||||
SplitTableContext helper = new SplitTableContext(Context)
|
||||
{
|
||||
EntityInfo = this.Context.EntityMaintenance.GetEntityInfo(type)
|
||||
};
|
||||
helper.CheckPrimaryKey();
|
||||
var tables = helper.GetTables();
|
||||
//var oldMapingTables = this.Context.MappingTables;
|
||||
if (tables.Count > 0)
|
||||
{
|
||||
foreach (var item in tables)
|
||||
{
|
||||
this.Context.MappingTables.Add(helper.EntityInfo.EntityName, item.TableName);
|
||||
this.Context.CodeFirst.InitTables(type);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Context.MappingTables.Add(helper.EntityInfo.EntityName, helper.GetDefaultTableName());
|
||||
this.Context.CodeFirst.InitTables(type);
|
||||
}
|
||||
this.Context.MappingTables.Add(helper.EntityInfo.EntityName, helper.EntityInfo.DbTableName);
|
||||
}
|
||||
|
||||
public void InitTables<T>(Type [] types)
|
||||
{
|
||||
foreach (var type in types)
|
||||
{
|
||||
InitTables(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -258,6 +258,20 @@ namespace SqlSugar
|
||||
this.Where(Regex.Split(sqlable.Key," Where ",RegexOptions.IgnoreCase).Last(), sqlable.Value);
|
||||
return this;
|
||||
}
|
||||
public SplitTableDeleteProvider<T> SplitTable(Func<List<SplitTableInfo>, IEnumerable<SplitTableInfo>> getTableNamesFunc)
|
||||
{
|
||||
this.Context.MappingTables.Add(this.EntityInfo.EntityName, this.EntityInfo.DbTableName);
|
||||
SplitTableDeleteProvider<T> result = new SplitTableDeleteProvider<T>();
|
||||
result.Context = this.Context;
|
||||
SplitTableContext helper = new SplitTableContext((SqlSugarProvider)Context)
|
||||
{
|
||||
EntityInfo = this.EntityInfo
|
||||
};
|
||||
var tables = getTableNamesFunc(helper.GetTables());
|
||||
result.Tables = tables;
|
||||
result.deleteobj = this;
|
||||
return result;
|
||||
}
|
||||
public IDeleteable<T> RemoveDataCache(string likeString)
|
||||
{
|
||||
this.RemoveCacheFunc = () =>
|
||||
|
@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class SplitTableDeleteProvider<T> where T : class, new()
|
||||
{
|
||||
public ISqlSugarClient Context;
|
||||
public DeleteableProvider<T> deleteobj;
|
||||
|
||||
public IEnumerable<SplitTableInfo> Tables { get; set; }
|
||||
public int ExecuteCommand()
|
||||
{
|
||||
if (this.Context.Ado.Transaction == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.Context.Ado.BeginTran();
|
||||
var result = _ExecuteCommand();
|
||||
this.Context.Ado.CommitTran();
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Context.Ado.RollbackTran();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _ExecuteCommand();
|
||||
}
|
||||
}
|
||||
public async Task<int> ExecuteCommandAsync()
|
||||
{
|
||||
if (this.Context.Ado.Transaction == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.Context.Ado.BeginTran();
|
||||
var result = await _ExecuteCommandAsync();
|
||||
this.Context.Ado.BeginTran();
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Context.Ado.RollbackTran();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await _ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
internal int _ExecuteCommand()
|
||||
{
|
||||
var result = 0;
|
||||
var sqlobj = deleteobj.ToSql();
|
||||
|
||||
foreach (var item in Tables)
|
||||
{
|
||||
var newsqlobj = GetSqlObj(sqlobj, item.TableName);
|
||||
result +=this.Context.Ado.ExecuteCommand(newsqlobj.Key, newsqlobj.Value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal async Task<int> _ExecuteCommandAsync()
|
||||
{
|
||||
var result = 0;
|
||||
var sqlobj = deleteobj.ToSql();
|
||||
foreach (var item in Tables)
|
||||
{
|
||||
var newsqlobj = GetSqlObj(sqlobj, item.TableName);
|
||||
result +=await this.Context.Ado.ExecuteCommandAsync(newsqlobj.Key, newsqlobj.Value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private KeyValuePair<string, List<SugarParameter>> GetSqlObj(KeyValuePair<string, List<SugarParameter>> keyValuePair,string asName)
|
||||
{
|
||||
List<SugarParameter> pars = new List<SugarParameter>();
|
||||
string sql = keyValuePair.Key;
|
||||
if (keyValuePair.Value != null)
|
||||
{
|
||||
pars = keyValuePair.Value.Select(it => new SugarParameter(it.ParameterName, it.Value)).ToList();
|
||||
}
|
||||
sql = Regex.Replace(sql, deleteobj.EntityInfo.DbTableName, asName,RegexOptions.IgnoreCase);
|
||||
return new KeyValuePair<string, List<SugarParameter>>(sql,pars);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -21,49 +21,45 @@ namespace SqlSugar
|
||||
return this.Context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey,
|
||||
() =>
|
||||
{
|
||||
EntityInfo result = new EntityInfo();
|
||||
var sugarAttributeInfo = type.GetTypeInfo().GetCustomAttributes(typeof(SugarTable), true).Where(it => it is SugarTable).SingleOrDefault();
|
||||
if (sugarAttributeInfo.HasValue())
|
||||
{
|
||||
var sugarTable = (SugarTable)sugarAttributeInfo;
|
||||
result.DbTableName = sugarTable.TableName;
|
||||
result.TableDescription = sugarTable.TableDescription;
|
||||
result.IsDisabledUpdateAll = sugarTable.IsDisabledUpdateAll;
|
||||
result.IsDisabledDelete = sugarTable.IsDisabledDelete;
|
||||
}
|
||||
if (this.Context.Context.CurrentConnectionConfig.ConfigureExternalServices != null && this.Context.CurrentConnectionConfig.ConfigureExternalServices.EntityNameService != null) {
|
||||
if (result.DbTableName == null)
|
||||
{
|
||||
result.DbTableName = type.Name;
|
||||
}
|
||||
this.Context.CurrentConnectionConfig.ConfigureExternalServices.EntityNameService(type,result);
|
||||
}
|
||||
result.Type = type;
|
||||
result.EntityName = result.Type.Name;
|
||||
result.Columns = new List<EntityColumnInfo>();
|
||||
SetColumns(result);
|
||||
return result;
|
||||
return GetEntityInfoNoCache(type);
|
||||
});
|
||||
}
|
||||
|
||||
public EntityInfo GetEntityInfoNoCache(Type type)
|
||||
{
|
||||
EntityInfo result = new EntityInfo();
|
||||
var sugarAttributeInfo = type.GetTypeInfo().GetCustomAttributes(typeof(SugarTable), true).Where(it => it is SugarTable).SingleOrDefault();
|
||||
if (sugarAttributeInfo.HasValue())
|
||||
{
|
||||
var sugarTable = (SugarTable)sugarAttributeInfo;
|
||||
result.DbTableName = sugarTable.TableName;
|
||||
result.TableDescription = sugarTable.TableDescription;
|
||||
result.IsDisabledUpdateAll = sugarTable.IsDisabledUpdateAll;
|
||||
result.IsDisabledDelete = sugarTable.IsDisabledDelete;
|
||||
}
|
||||
if (this.Context.Context.CurrentConnectionConfig.ConfigureExternalServices != null && this.Context.CurrentConnectionConfig.ConfigureExternalServices.EntityNameService != null)
|
||||
{
|
||||
if (result.DbTableName == null)
|
||||
{
|
||||
result.DbTableName = type.Name;
|
||||
}
|
||||
this.Context.CurrentConnectionConfig.ConfigureExternalServices.EntityNameService(type, result);
|
||||
}
|
||||
result.Type = type;
|
||||
result.EntityName = result.Type.Name;
|
||||
result.Columns = new List<EntityColumnInfo>();
|
||||
SetColumns(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public string GetTableName<T>()
|
||||
{
|
||||
var typeName = typeof(T).Name;
|
||||
if (this.Context.MappingTables == null || this.Context.MappingTables.Count == 0)
|
||||
{
|
||||
var entity = this.GetEntityInfo<T>();
|
||||
if (entity.DbTableName.HasValue()) return entity.DbTableName;
|
||||
else return entity.EntityName;
|
||||
}
|
||||
else
|
||||
{
|
||||
var mappingInfo = this.Context.MappingTables.SingleOrDefault(it => it.EntityName == typeName);
|
||||
return mappingInfo == null ? typeName : mappingInfo.DbTableName;
|
||||
}
|
||||
return GetTableName(typeof(T));
|
||||
}
|
||||
public string GetTableName(Type entityType)
|
||||
{
|
||||
var typeName = entityType.Name;
|
||||
if (this.Context.MappingTables == null || this.Context.MappingTables.Count == 0)
|
||||
if (this.Context.MappingTables == null || this.Context.MappingTables.Count == 0 || !this.Context.MappingTables.Any(it => it.EntityName == typeName))
|
||||
{
|
||||
var entity = this.GetEntityInfo(entityType);
|
||||
if (entity.DbTableName.HasValue()) return entity.DbTableName;
|
||||
@ -96,27 +92,14 @@ namespace SqlSugar
|
||||
}
|
||||
public string GetDbColumnName<T>(string propertyName)
|
||||
{
|
||||
var isAny = this.GetEntityInfo<T>().Columns.Any(it => it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
|
||||
Check.Exception(!isAny, "Property " + propertyName + " is Invalid");
|
||||
var typeName = typeof(T).Name;
|
||||
if (this.Context.MappingColumns == null || this.Context.MappingColumns.Count == 0)
|
||||
{
|
||||
var column= this.GetEntityInfo<T>().Columns.First(it => it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
|
||||
if (column.DbColumnName.HasValue()) return column.DbColumnName;
|
||||
else return column.PropertyName;
|
||||
}
|
||||
else
|
||||
{
|
||||
var mappingInfo = this.Context.MappingColumns.SingleOrDefault(it => it.EntityName == typeName && it.PropertyName == propertyName);
|
||||
return mappingInfo == null ? propertyName : mappingInfo.DbColumnName;
|
||||
}
|
||||
return GetDbColumnName(propertyName,typeof(T));
|
||||
}
|
||||
public string GetDbColumnName(string propertyName,Type entityType)
|
||||
{
|
||||
var isAny = this.GetEntityInfo(entityType).Columns.Any(it => it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
|
||||
Check.Exception(!isAny, "Property " + propertyName + " is Invalid");
|
||||
var typeName = entityType.Name;
|
||||
if (this.Context.MappingColumns == null || this.Context.MappingColumns.Count == 0)
|
||||
if (this.Context.MappingColumns == null || this.Context.MappingColumns.Count == 0 || !this.Context.MappingColumns.Any(it => it.EntityName == typeName && it.PropertyName == propertyName))
|
||||
{
|
||||
var column = this.GetEntityInfo(entityType).Columns.First(it => it.PropertyName.Equals(propertyName, StringComparison.CurrentCultureIgnoreCase));
|
||||
if (column.DbColumnName.HasValue()) return column.DbColumnName;
|
||||
|
@ -14,15 +14,15 @@ namespace SqlSugar
|
||||
{
|
||||
if (_Filters == null)
|
||||
_Filters = new List<SqlFilterItem>();
|
||||
if (this.Context.CurrentConnectionConfig.IsShardSameThread)
|
||||
{
|
||||
if (!_Filters.Select(it => it.FilterValue(this.Context).Sql).Contains(filter.FilterValue(this.Context).Sql))
|
||||
_Filters.Add(filter);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (this.Context.CurrentConnectionConfig.IsShardSameThread)
|
||||
//{
|
||||
// if (!_Filters.Select(it => it.FilterValue(this.Context).Sql).Contains(filter.FilterValue(this.Context).Sql))
|
||||
// _Filters.Add(filter);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
_Filters.Add(filter);
|
||||
}
|
||||
//}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -22,7 +23,7 @@ namespace SqlSugar
|
||||
public EntityInfo EntityInfo { get; set; }
|
||||
public List<MappingColumn> MappingColumnList { get; set; }
|
||||
private List<string> IgnoreColumnNameList { get; set; }
|
||||
private bool IsOffIdentity { get; set; }
|
||||
internal bool IsOffIdentity { get; set; }
|
||||
public T[] InsertObjs { get; set; }
|
||||
|
||||
public MappingTableList OldMappingTableList { get; set; }
|
||||
@ -406,6 +407,42 @@ namespace SqlSugar
|
||||
result.AddSubList(tree);
|
||||
return result;
|
||||
}
|
||||
public SplitInsertable<T> SplitTable(SplitType splitType)
|
||||
{
|
||||
SplitTableContext helper = new SplitTableContext(Context)
|
||||
{
|
||||
EntityInfo = this.EntityInfo
|
||||
};
|
||||
helper.CheckPrimaryKey();
|
||||
SplitInsertable<T> result = new SplitInsertable<T>();
|
||||
result.Context = this.Context;
|
||||
result.EntityInfo = this.EntityInfo;
|
||||
result.Helper = helper;
|
||||
result.SplitType = splitType;
|
||||
result.TableNames = new List<KeyValuePair<string, object>>();
|
||||
foreach (var item in this.InsertObjs)
|
||||
{
|
||||
var splitFieldValue = helper.GetValue(splitType, item);
|
||||
var tableName=helper.GetTableName(splitType, splitFieldValue);
|
||||
result.TableNames.Add(new KeyValuePair<string, object>(tableName,item));
|
||||
}
|
||||
result.Inserable = this;
|
||||
return result;
|
||||
}
|
||||
|
||||
public SplitInsertable<T> SplitTable()
|
||||
{
|
||||
var splitTableAttribute = typeof(T).GetCustomAttribute<SplitTableAttribute>();
|
||||
if (splitTableAttribute != null)
|
||||
{
|
||||
return SplitTable((splitTableAttribute as SplitTableAttribute).SplitType);
|
||||
}
|
||||
else
|
||||
{
|
||||
Check.Exception(true,$" {typeof(T).Name} need SplitTableAttribute");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -0,0 +1,226 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class SplitInsertable<T> where T:class ,new()
|
||||
{
|
||||
public SqlSugarProvider Context;
|
||||
internal SplitTableContext Helper;
|
||||
public EntityInfo EntityInfo;
|
||||
public SplitType SplitType;
|
||||
internal IInsertable<T> Inserable { get; set; }
|
||||
internal List<KeyValuePair<string,object>> TableNames { get; set; }
|
||||
|
||||
public int ExecuteCommand()
|
||||
{
|
||||
if (this.Context.Ado.Transaction == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.Context.Ado.BeginTran();
|
||||
var result = _ExecuteCommand();
|
||||
this.Context.Ado.CommitTran();
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Context.Ado.RollbackTran();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _ExecuteCommand();
|
||||
}
|
||||
}
|
||||
public async Task<int> ExecuteCommandAsync()
|
||||
{
|
||||
if (this.Context.Ado.Transaction == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.Context.Ado.BeginTran();
|
||||
var result = await _ExecuteCommandAsync();
|
||||
this.Context.Ado.BeginTran();
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Context.Ado.RollbackTran();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await _ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<long> ExecuteReturnSnowflakeIdList()
|
||||
{
|
||||
if (this.Context.Ado.Transaction == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.Context.Ado.BeginTran();
|
||||
var result = _ExecuteReturnSnowflakeIdList();
|
||||
this.Context.Ado.CommitTran();
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Context.Ado.RollbackTran();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _ExecuteReturnSnowflakeIdList();
|
||||
}
|
||||
}
|
||||
public async Task<List<long>> ExecuteReturnSnowflakeIdListAsync()
|
||||
{
|
||||
if (this.Context.Ado.Transaction == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.Context.Ado.BeginTran();
|
||||
var result = await _ExecuteReturnSnowflakeIdListAsync();
|
||||
this.Context.Ado.BeginTran();
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Context.Ado.RollbackTran();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await _ExecuteReturnSnowflakeIdListAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public long ExecuteReturnSnowflakeId()
|
||||
{
|
||||
return ExecuteReturnSnowflakeIdList().FirstOrDefault();
|
||||
}
|
||||
public async Task<long> ExecuteReturnSnowflakeIdAsync()
|
||||
{
|
||||
var list = await ExecuteReturnSnowflakeIdListAsync();
|
||||
return list.FirstOrDefault();
|
||||
}
|
||||
|
||||
|
||||
internal int _ExecuteCommand()
|
||||
{
|
||||
CreateTable();
|
||||
var result = 0;
|
||||
var groups = TableNames.GroupBy(it => it.Key).ToList();
|
||||
var parent = ((InsertableProvider<T>)Inserable);
|
||||
var names = parent.InsertBuilder.DbColumnInfoList.GroupBy(it => it.DbColumnName).Select(i => i.Key).ToList();
|
||||
foreach (var item in groups)
|
||||
{
|
||||
var list = item.Select(it => it.Value as T).ToList();
|
||||
var groupInserable = (InsertableProvider<T>)this.Context.Insertable<T>(list);
|
||||
groupInserable.InsertBuilder.TableWithString = parent.InsertBuilder.TableWithString;
|
||||
groupInserable.RemoveCacheFunc = parent.RemoveCacheFunc;
|
||||
groupInserable.diffModel = parent.diffModel;
|
||||
groupInserable.IsEnableDiffLogEvent = parent.IsEnableDiffLogEvent;
|
||||
groupInserable.InsertBuilder.IsNoInsertNull = parent.InsertBuilder.IsNoInsertNull;
|
||||
groupInserable.IsOffIdentity = parent.IsOffIdentity;
|
||||
result += groupInserable.AS(item.Key).InsertColumns(names.ToArray()).ExecuteCommand();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
internal async Task<int> _ExecuteCommandAsync()
|
||||
{
|
||||
CreateTable();
|
||||
var result = 0;
|
||||
var groups = TableNames.GroupBy(it => it.Key).ToList();
|
||||
var parent = ((InsertableProvider<T>)Inserable);
|
||||
var names = parent.InsertBuilder.DbColumnInfoList.GroupBy(it => it.DbColumnName).Select(i => i.Key).ToList();
|
||||
foreach (var item in groups)
|
||||
{
|
||||
var list = item.Select(it => it.Value as T).ToList();
|
||||
var groupInserable = (InsertableProvider<T>)this.Context.Insertable<T>(list);
|
||||
groupInserable.InsertBuilder.TableWithString = parent.InsertBuilder.TableWithString;
|
||||
groupInserable.RemoveCacheFunc = parent.RemoveCacheFunc;
|
||||
groupInserable.diffModel = parent.diffModel;
|
||||
groupInserable.IsEnableDiffLogEvent = parent.IsEnableDiffLogEvent;
|
||||
groupInserable.InsertBuilder.IsNoInsertNull = parent.InsertBuilder.IsNoInsertNull;
|
||||
groupInserable.IsOffIdentity = parent.IsOffIdentity;
|
||||
result +=await groupInserable.AS(item.Key).InsertColumns(names.ToArray()).ExecuteCommandAsync();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal List<long> _ExecuteReturnSnowflakeIdList()
|
||||
{
|
||||
CreateTable();
|
||||
var result = new List<long>();
|
||||
var groups = TableNames.GroupBy(it => it.Key).ToList();
|
||||
var parent = ((InsertableProvider<T>)Inserable);
|
||||
var names = parent.InsertBuilder.DbColumnInfoList.GroupBy(it => it.DbColumnName).Select(i => i.Key).ToList();
|
||||
foreach (var item in groups)
|
||||
{
|
||||
var list = item.Select(it => it.Value as T).ToList();
|
||||
var groupInserable = (InsertableProvider<T>)this.Context.Insertable<T>(list);
|
||||
groupInserable.InsertBuilder.TableWithString = parent.InsertBuilder.TableWithString;
|
||||
groupInserable.RemoveCacheFunc = parent.RemoveCacheFunc;
|
||||
groupInserable.diffModel = parent.diffModel;
|
||||
groupInserable.IsEnableDiffLogEvent = parent.IsEnableDiffLogEvent;
|
||||
groupInserable.InsertBuilder.IsNoInsertNull = parent.InsertBuilder.IsNoInsertNull;
|
||||
groupInserable.IsOffIdentity = parent.IsOffIdentity;
|
||||
var idList= groupInserable.AS(item.Key).InsertColumns(names.ToArray()).ExecuteReturnSnowflakeIdList();
|
||||
result.AddRange(idList);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
internal async Task<List<long>> _ExecuteReturnSnowflakeIdListAsync()
|
||||
{
|
||||
CreateTable();
|
||||
var result = new List<long>();
|
||||
var groups = TableNames.GroupBy(it => it.Key).ToList();
|
||||
var parent = ((InsertableProvider<T>)Inserable);
|
||||
var names = parent.InsertBuilder.DbColumnInfoList.GroupBy(it => it.DbColumnName).Select(i => i.Key).ToList();
|
||||
foreach (var item in groups)
|
||||
{
|
||||
var list = item.Select(it => it.Value as T).ToList();
|
||||
var groupInserable = (InsertableProvider<T>)this.Context.Insertable<T>(list);
|
||||
groupInserable.InsertBuilder.TableWithString = parent.InsertBuilder.TableWithString;
|
||||
groupInserable.RemoveCacheFunc = parent.RemoveCacheFunc;
|
||||
groupInserable.diffModel = parent.diffModel;
|
||||
groupInserable.IsEnableDiffLogEvent = parent.IsEnableDiffLogEvent;
|
||||
groupInserable.InsertBuilder.IsNoInsertNull = parent.InsertBuilder.IsNoInsertNull;
|
||||
groupInserable.IsOffIdentity = parent.IsOffIdentity;
|
||||
var idList =await groupInserable.AS(item.Key).InsertColumns(names.ToArray()).ExecuteReturnSnowflakeIdListAsync();
|
||||
result.AddRange(idList);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private void CreateTable()
|
||||
{
|
||||
var isLog = this.Context.Ado.IsEnableLogEvent;
|
||||
this.Context.Ado.IsEnableLogEvent = false;
|
||||
foreach (var item in TableNames)
|
||||
{
|
||||
if (!this.Context.DbMaintenance.IsAnyTable(item.Key, false))
|
||||
{
|
||||
this.Context.MappingTables.Add(EntityInfo.EntityName, item.Key);
|
||||
this.Context.CodeFirst.InitTables<T>();
|
||||
}
|
||||
}
|
||||
this.Context.Ado.IsEnableLogEvent = isLog;
|
||||
this.Context.MappingTables.Add(EntityInfo.EntityName, EntityInfo.DbTableName);
|
||||
}
|
||||
}
|
||||
}
|
@ -46,6 +46,57 @@ namespace SqlSugar
|
||||
return this.Context.EntityMaintenance.GetEntityInfo<T>();
|
||||
}
|
||||
}
|
||||
public ISugarQueryable<T, T2> LeftJoin<T2>(ISugarQueryable<T2> joinQueryable, Expression<Func<T, T2, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T2>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Left);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2> InnerJoin<T2>(ISugarQueryable<T2> joinQueryable, Expression<Func<T, T2, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T2>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Inner);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2> RightJoin<T2>(ISugarQueryable<T2> joinQueryable, Expression<Func<T, T2, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T2>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Right);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2> LeftJoin<T2>(Expression<Func<T, T2, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T2>();
|
||||
@ -790,10 +841,14 @@ namespace SqlSugar
|
||||
var selectValue = new SugarMapper(this.Context).GetSelectValue<TResult>(this.QueryBuilder);
|
||||
return this.Select<TResult>(selectValue);
|
||||
}
|
||||
else if (this.QueryBuilder.EntityType == UtilConstants.ObjType || (this.QueryBuilder.AsTables != null && this.QueryBuilder.AsTables.Count == 1)||this.QueryBuilder.EntityName!=this.QueryBuilder.EntityType.Name)
|
||||
{
|
||||
return this.Select<TResult>(this.SqlBuilder.SqlSelectAll);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return this.Select<TResult>(this.SqlBuilder.SqlSelectAll);
|
||||
var selects = this.QueryBuilder.GetSelectValueByString();
|
||||
return this.Select<TResult>(selects);
|
||||
}
|
||||
}
|
||||
|
||||
@ -819,9 +874,9 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual ISugarQueryable<T> MergeTable()
|
||||
{
|
||||
Check.Exception(this.MapperAction != null || this.MapperActionWithCache != null, "'Mapper’ needs to be written after ‘MergeTable’ ");
|
||||
Check.Exception(this.QueryBuilder.SelectValue.IsNullOrEmpty(), "MergeTable need to use Queryable.Select Method .");
|
||||
Check.Exception(this.QueryBuilder.Skip > 0 || this.QueryBuilder.Take > 0 || this.QueryBuilder.OrderByValue.HasValue(), "MergeTable Queryable cannot Take Skip OrderBy PageToList ");
|
||||
Check.Exception(this.MapperAction != null || this.MapperActionWithCache != null,ErrorMessage.GetThrowMessage( "'Mapper’ needs to be written after ‘MergeTable’ ", "Mapper 只能在 MergeTable 之后使用"));
|
||||
Check.Exception(this.QueryBuilder.SelectValue.IsNullOrEmpty(),ErrorMessage.GetThrowMessage( "MergeTable need to use Queryable.Select Method .", "使用MergeTable之前必须要有Queryable.Select方法"));
|
||||
Check.Exception(this.QueryBuilder.Skip > 0 || this.QueryBuilder.Take > 0 || this.QueryBuilder.OrderByValue.HasValue(),ErrorMessage.GetThrowMessage( "MergeTable Queryable cannot Take Skip OrderBy PageToList ", "使用 MergeTable不能有 Take Skip OrderBy PageToList 等操作,你可以在Mergetable之后操作"));
|
||||
var sqlobj = this._ToSql();
|
||||
var index = QueryBuilder.WhereIndex + 1;
|
||||
var result = this.Context.Queryable<T>().AS(SqlBuilder.GetPackTable(sqlobj.Key, "MergeTable")).AddParameters(sqlobj.Value).Select("*").With(SqlWith.Null);
|
||||
@ -834,7 +889,25 @@ namespace SqlSugar
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public ISugarQueryable<T> SplitTable(Func<List<SplitTableInfo>, IEnumerable<SplitTableInfo>> getTableNamesFunc)
|
||||
{
|
||||
SplitTableContext helper = new SplitTableContext(Context)
|
||||
{
|
||||
EntityInfo = this.EntityInfo
|
||||
};
|
||||
this.Context.MappingTables.Add(this.EntityInfo.EntityName, this.EntityInfo.DbTableName);
|
||||
var tables = getTableNamesFunc(helper.GetTables());
|
||||
List<ISugarQueryable<T>> tableQueryables = new List<ISugarQueryable<T>>();
|
||||
foreach (var item in tables)
|
||||
{
|
||||
tableQueryables.Add(this.Clone().AS(item.TableName));
|
||||
}
|
||||
Check.Exception(tableQueryables.Count == 0, ErrorMessage.GetThrowMessage("SplitTable error . There are no tables after filtering", "SplitTable没有筛选出分表,请检查条件和数据库中的表"));
|
||||
var unionall = this.Context._UnionAll(tableQueryables.ToArray());
|
||||
//var values= unionall.QueryBuilder.GetSelectValue;
|
||||
//unionall.QueryBuilder.SelectValue = values;
|
||||
return unionall;
|
||||
}
|
||||
public ISugarQueryable<T> Distinct()
|
||||
{
|
||||
QueryBuilder.IsDistinct = true;
|
||||
@ -1627,6 +1700,12 @@ namespace SqlSugar
|
||||
{
|
||||
var firstPareamter = (express as LambdaExpression).Parameters.First();
|
||||
this.QueryBuilder.TableShortName = firstPareamter.Name;
|
||||
if (this.QueryBuilder.AsTables != null && this.QueryBuilder.AsTables.Count==1)
|
||||
{
|
||||
var tableinfo = this.QueryBuilder.AsTables.First();
|
||||
this.QueryBuilder.AsTables[tableinfo.Key] =" (SELECT * FROM " +this.QueryBuilder.AsTables.First().Value+")";
|
||||
this.QueryBuilder.SelectValue = this.QueryBuilder.TableShortName +".*";
|
||||
}
|
||||
}
|
||||
Check.Exception(result.JoinIndex > 10, ErrorMessage.GetThrowMessage("只支持12个表", "Only 12 tables are supported"));
|
||||
return result;
|
||||
@ -2501,6 +2580,57 @@ namespace SqlSugar
|
||||
#region T2
|
||||
public partial class QueryableProvider<T, T2> : QueryableProvider<T>, ISugarQueryable<T, T2>
|
||||
{
|
||||
public ISugarQueryable<T, T2,T3> LeftJoin<T3>(ISugarQueryable<T3> joinQueryable, Expression<Func<T, T2,T3, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T3>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2,T3>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Left);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2,T3> InnerJoin<T3>(ISugarQueryable<T3> joinQueryable, Expression<Func<T, T2,T3, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T3>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Inner);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2,T3> RightJoin<T3>(ISugarQueryable<T3> joinQueryable, Expression<Func<T, T2,T3, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T3>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Right);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2,T3> LeftJoin<T3>(Expression<Func<T, T2,T3, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T3>();
|
||||
@ -2858,6 +2988,57 @@ namespace SqlSugar
|
||||
#region T3
|
||||
public partial class QueryableProvider<T, T2, T3> : QueryableProvider<T>, ISugarQueryable<T, T2, T3>
|
||||
{
|
||||
public ISugarQueryable<T, T2, T3,T4> LeftJoin<T4>(ISugarQueryable<T4> joinQueryable, Expression<Func<T, T2, T3,T4, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T4>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3,T4>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Left);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3,T4> InnerJoin<T4>(ISugarQueryable<T4> joinQueryable, Expression<Func<T, T2, T3,T4, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T4>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Inner);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3,T4> RightJoin<T4>(ISugarQueryable<T4> joinQueryable, Expression<Func<T, T2, T3,T4, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T4>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Right);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3,T4> LeftJoin<T4>(Expression<Func<T, T2, T3,T4, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T4>();
|
||||
@ -3280,6 +3461,57 @@ namespace SqlSugar
|
||||
#region T4
|
||||
public partial class QueryableProvider<T, T2, T3, T4> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4>
|
||||
{
|
||||
public ISugarQueryable<T, T2, T3, T4,T5> LeftJoin<T5>(ISugarQueryable<T5> joinQueryable, Expression<Func<T, T2, T3, T4, T5, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T5>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4,T5>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Left);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4,T5> InnerJoin<T5>(ISugarQueryable<T5> joinQueryable, Expression<Func<T, T2, T3, T4,T5, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T5>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Inner);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4,T5> RightJoin<T5>(ISugarQueryable<T5> joinQueryable, Expression<Func<T, T2, T3, T4,T5, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T5>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Right);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5> LeftJoin<T5>(Expression<Func<T, T2, T3, T4,T5, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T5>();
|
||||
@ -3743,6 +3975,57 @@ namespace SqlSugar
|
||||
#region T5
|
||||
public partial class QueryableProvider<T, T2, T3, T4, T5> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5>
|
||||
{
|
||||
public ISugarQueryable<T, T2, T3, T4, T5,T6> LeftJoin<T6>(ISugarQueryable<T6> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T6>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Left);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6> InnerJoin<T6>(ISugarQueryable<T6> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T6>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Inner);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6> RightJoin<T6>(ISugarQueryable<T6> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T6>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Right);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6> LeftJoin<T6>(Expression<Func<T, T2, T3, T4, T5,T6, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T6>();
|
||||
@ -4168,6 +4451,57 @@ namespace SqlSugar
|
||||
#region T6
|
||||
public partial class QueryableProvider<T, T2, T3, T4, T5, T6> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6>
|
||||
{
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6,T7> LeftJoin<T7>(ISugarQueryable<T7> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T7>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Left);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> InnerJoin<T7>(ISugarQueryable<T7> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T7>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Inner);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> RightJoin<T7>(ISugarQueryable<T7> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T7>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Right);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7> LeftJoin<T7>(Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T7>();
|
||||
@ -4627,6 +4961,57 @@ namespace SqlSugar
|
||||
#region T7
|
||||
public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7>
|
||||
{
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> LeftJoin<T8>(ISugarQueryable<T8> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T8>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Left);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> InnerJoin<T8>(ISugarQueryable<T8> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T8>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Inner);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> RightJoin<T8>(ISugarQueryable<T8> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T8>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Right);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> LeftJoin<T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T8>();
|
||||
@ -5077,6 +5462,57 @@ namespace SqlSugar
|
||||
#region T8
|
||||
public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8>
|
||||
{
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> LeftJoin<T9>(ISugarQueryable<T9> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T9>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Left);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> InnerJoin<T9>(ISugarQueryable<T9> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T9>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Inner);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> RightJoin<T9>(ISugarQueryable<T9> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T9>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Right);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> LeftJoin<T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T9>();
|
||||
@ -5560,6 +5996,57 @@ namespace SqlSugar
|
||||
#region T9
|
||||
public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>
|
||||
{
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> LeftJoin<T10>(ISugarQueryable<T10> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T10>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Left);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> InnerJoin<T10>(ISugarQueryable<T10> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T10>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Inner);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> RightJoin<T10>(ISugarQueryable<T10> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T10>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Right);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> LeftJoin<T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T10>();
|
||||
@ -5796,6 +6283,67 @@ namespace SqlSugar
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, string orderFileds)
|
||||
{
|
||||
if (isOrderBy)
|
||||
base.OrderBy(orderFileds);
|
||||
return this;
|
||||
}
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GroupBy
|
||||
@ -5979,6 +6527,57 @@ namespace SqlSugar
|
||||
#region T10
|
||||
public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>
|
||||
{
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> LeftJoin<T11>(ISugarQueryable<T11> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T11>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Left);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> InnerJoin<T11>(ISugarQueryable<T11> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T11>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Inner);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> RightJoin<T11>(ISugarQueryable<T11> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T11>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Right);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> LeftJoin<T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T11>();
|
||||
@ -6235,6 +6834,73 @@ namespace SqlSugar
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, string orderFileds)
|
||||
{
|
||||
if (isOrderBy)
|
||||
base.OrderBy(orderFileds);
|
||||
return this;
|
||||
}
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GroupBy
|
||||
@ -6423,6 +7089,57 @@ namespace SqlSugar
|
||||
#region T11
|
||||
public partial class QueryableProvider<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : QueryableProvider<T>, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>
|
||||
{
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> LeftJoin<T12>(ISugarQueryable<T12> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T12>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Left);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> InnerJoin<T12>(ISugarQueryable<T12> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T12>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Inner);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> RightJoin<T12>(ISugarQueryable<T12> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T12>();
|
||||
var result = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this.Context.CurrentConnectionConfig);
|
||||
result.SqlBuilder = this.SqlBuilder;
|
||||
result.Context = this.Context;
|
||||
var joinInfo = GetJoinInfo(joinExpression, JoinType.Right);
|
||||
var sqlObject = joinQueryable.ToSql();
|
||||
string sql = sqlObject.Key;
|
||||
this.QueryBuilder.LambdaExpressions.ParameterIndex += 100;
|
||||
UtilMethods.RepairReplicationParameters(ref sql, sqlObject.Value.ToArray(), this.QueryBuilder.LambdaExpressions.ParameterIndex, "");
|
||||
joinInfo.TableName = "(" + sql + ")";
|
||||
this.QueryBuilder.Parameters.AddRange(sqlObject.Value);
|
||||
result.QueryBuilder.JoinQueryInfos.Add(joinInfo);
|
||||
result.QueryBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||
return result;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> LeftJoin<T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, bool>> joinExpression)
|
||||
{
|
||||
this.Context.InitMappingInfo<T12>();
|
||||
@ -6698,6 +7415,79 @@ namespace SqlSugar
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> OrderByIF(bool isOrderBy, string orderFileds)
|
||||
{
|
||||
if (isOrderBy)
|
||||
base.OrderBy(orderFileds);
|
||||
return this;
|
||||
}
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GroupBy
|
||||
@ -7159,6 +7949,84 @@ namespace SqlSugar
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, string orderFileds)
|
||||
{
|
||||
if (isOrderBy)
|
||||
base.OrderBy(orderFileds);
|
||||
return this;
|
||||
}
|
||||
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, object>> expression, OrderByType type = OrderByType.Asc)
|
||||
{
|
||||
if (isOrderBy)
|
||||
_OrderBy(expression, type);
|
||||
return this;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GroupBy
|
||||
|
@ -162,7 +162,11 @@ namespace SqlSugar
|
||||
var copyObj = CopyEntityInfo(entityInfo);
|
||||
InitMappingInfo(copyObj);
|
||||
}
|
||||
|
||||
public void InitMappingInfoNoCache(Type type)
|
||||
{
|
||||
var entityInfo = this.Context.EntityMaintenance.GetEntityInfoNoCache(type);
|
||||
InitMappingInfo(entityInfo);
|
||||
}
|
||||
private EntityInfo CopyEntityInfo(EntityInfo entityInfo)
|
||||
{
|
||||
EntityInfo result = new EntityInfo()
|
||||
|
@ -504,6 +504,11 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
public virtual ISugarQueryable<T> UnionAll<T>(params ISugarQueryable<T>[] queryables) where T : class, new()
|
||||
{
|
||||
return _UnionAll(queryables);
|
||||
}
|
||||
|
||||
internal ISugarQueryable<T> _UnionAll<T>(ISugarQueryable<T>[] queryables)
|
||||
{
|
||||
var sqlBuilder = InstanceFactory.GetSqlbuilder(this.Context.CurrentConnectionConfig);
|
||||
Check.Exception(queryables.IsNullOrEmpty(), "UnionAll.queryables is null ");
|
||||
@ -533,6 +538,7 @@ namespace SqlSugar
|
||||
return resulut.Select<T>(sqlBuilder.SqlSelectAll);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual ISugarQueryable<T> UnionAll<T>(List<ISugarQueryable<T>> queryables) where T : class, new()
|
||||
{
|
||||
Check.Exception(queryables.IsNullOrEmpty(), "UnionAll.queryables is null ");
|
||||
@ -1127,5 +1133,40 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Split table
|
||||
public SplitTableContext SplitHelper<T>() where T : class, new()
|
||||
{
|
||||
var result = new SplitTableContext(this.Context)
|
||||
{
|
||||
EntityInfo = this.Context.EntityMaintenance.GetEntityInfo<T>()
|
||||
};
|
||||
return result;
|
||||
}
|
||||
public SplitTableContextResult<T> SplitHelper<T>(T data) where T : class, new()
|
||||
{
|
||||
var result = new SplitTableContext(this.Context)
|
||||
{
|
||||
EntityInfo = this.Context.EntityMaintenance.GetEntityInfo<T>()
|
||||
};
|
||||
return new SplitTableContextResult<T>()
|
||||
{
|
||||
Items = new List<T> { data },
|
||||
Helper = result
|
||||
};
|
||||
}
|
||||
public SplitTableContextResult<T> SplitHelper<T>(List<T> data) where T : class, new()
|
||||
{
|
||||
var result = new SplitTableContext(this.Context)
|
||||
{
|
||||
EntityInfo = this.Context.EntityMaintenance.GetEntityInfo<T>()
|
||||
};
|
||||
return new SplitTableContextResult<T>()
|
||||
{
|
||||
Items = data,
|
||||
Helper = result
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class SplitTableUpdateProvider<T> where T : class, new()
|
||||
{
|
||||
public SqlSugarProvider Context;
|
||||
public UpdateableProvider<T> updateobj;
|
||||
|
||||
public IEnumerable<SplitTableInfo> Tables { get; set; }
|
||||
|
||||
public int ExecuteCommand()
|
||||
{
|
||||
if (this.Context.Ado.Transaction == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.Context.Ado.BeginTran();
|
||||
var result = _ExecuteCommand();
|
||||
this.Context.Ado.CommitTran();
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Context.Ado.RollbackTran();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _ExecuteCommand();
|
||||
}
|
||||
}
|
||||
public async Task<int> ExecuteCommandAsync()
|
||||
{
|
||||
if (this.Context.Ado.Transaction == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.Context.Ado.BeginTran();
|
||||
var result = await _ExecuteCommandAsync();
|
||||
this.Context.Ado.BeginTran();
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Context.Ado.RollbackTran();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await _ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
private int _ExecuteCommand()
|
||||
{
|
||||
var result = 0;
|
||||
var sqlobj = updateobj.ToSql();
|
||||
|
||||
foreach (var item in Tables)
|
||||
{
|
||||
var newsqlobj = GetSqlObj(sqlobj, item.TableName);
|
||||
result += this.Context.Ado.ExecuteCommand(newsqlobj.Key, newsqlobj.Value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<int> _ExecuteCommandAsync()
|
||||
{
|
||||
var result = 0;
|
||||
var sqlobj = updateobj.ToSql();
|
||||
foreach (var item in Tables)
|
||||
{
|
||||
var newsqlobj = GetSqlObj(sqlobj, item.TableName);
|
||||
result += await this.Context.Ado.ExecuteCommandAsync(newsqlobj.Key, newsqlobj.Value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private KeyValuePair<string, List<SugarParameter>> GetSqlObj(KeyValuePair<string, List<SugarParameter>> keyValuePair, string asName)
|
||||
{
|
||||
List<SugarParameter> pars = new List<SugarParameter>();
|
||||
string sql = keyValuePair.Key;
|
||||
if (keyValuePair.Value != null)
|
||||
{
|
||||
pars = keyValuePair.Value.Select(it => new SugarParameter(it.ParameterName, it.Value)).ToList();
|
||||
}
|
||||
sql = Regex.Replace(sql, updateobj.EntityInfo.DbTableName, asName, RegexOptions.IgnoreCase);
|
||||
return new KeyValuePair<string, List<SugarParameter>>(sql, pars);
|
||||
}
|
||||
}
|
||||
}
|
@ -89,6 +89,20 @@ namespace SqlSugar
|
||||
this.UpdateBuilder.TableWithString = lockString;
|
||||
return this;
|
||||
}
|
||||
public SplitTableUpdateProvider<T> SplitTable(Func<List<SplitTableInfo>, IEnumerable<SplitTableInfo>> getTableNamesFunc)
|
||||
{
|
||||
this.Context.MappingTables.Add(this.EntityInfo.EntityName, this.EntityInfo.DbTableName);
|
||||
SplitTableUpdateProvider<T> result = new SplitTableUpdateProvider<T>();
|
||||
result.Context = this.Context;
|
||||
SplitTableContext helper = new SplitTableContext(Context)
|
||||
{
|
||||
EntityInfo = this.EntityInfo
|
||||
};
|
||||
var tables = getTableNamesFunc(helper.GetTables());
|
||||
result.Tables = tables;
|
||||
result.updateobj= this;
|
||||
return result;
|
||||
}
|
||||
public IUpdateable<T> RemoveDataCache()
|
||||
{
|
||||
this.RemoveCacheFunc = () =>
|
||||
|
@ -10,7 +10,7 @@ namespace SqlSugar
|
||||
public class ConnectionConfig
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
///Connection unique code
|
||||
/// </summary>
|
||||
public dynamic ConfigId { get; set; }
|
||||
/// <summary>
|
||||
@ -30,10 +30,14 @@ namespace SqlSugar
|
||||
/// </summary>
|
||||
public InitKeyType InitKeyType = InitKeyType.Attribute;
|
||||
/// <summary>
|
||||
///If true, there is only one connection instance in the same thread within the same connection string
|
||||
[Obsolete("use SqlSugar.Ioc")]
|
||||
/// Exception prompt language
|
||||
/// </summary>
|
||||
public bool IsShardSameThread { get; set; }
|
||||
public LanguageType LanguageType { get=>ErrorMessage.SugarLanguageType; set=>ErrorMessage.SugarLanguageType=value; }
|
||||
/// <summary>
|
||||
///If true, there is only one connection instance in the same thread within the same connection string
|
||||
//[Obsolete("use SqlSugar.Ioc")]
|
||||
///// </summary>
|
||||
//public bool IsShardSameThread { get; set; }
|
||||
/// <summary>
|
||||
/// Configure External Services replace default services,For example, Redis storage
|
||||
/// </summary>
|
||||
@ -48,10 +52,10 @@ namespace SqlSugar
|
||||
/// More Gobal Settings
|
||||
/// </summary>
|
||||
public ConnMoreSettings MoreSettings { get; set; }
|
||||
/// <summary>
|
||||
/// Used for debugging errors or BUG,Used for debugging, which has an impact on Performance
|
||||
/// </summary>
|
||||
public SugarDebugger Debugger { get; set; }
|
||||
///// <summary>
|
||||
///// Used for debugging errors or BUG,Used for debugging, which has an impact on Performance
|
||||
///// </summary>
|
||||
//public SugarDebugger Debugger { get; set; }
|
||||
|
||||
public string IndexSuffix { get; set; }
|
||||
|
||||
@ -75,7 +79,7 @@ namespace SqlSugar
|
||||
private ICacheService _ReflectionInoCache;
|
||||
private ICacheService _DataInfoCache;
|
||||
private IRazorService _RazorService;
|
||||
|
||||
public ISplitTableService SplitTableService { get; set; }
|
||||
public IRazorService RazorService
|
||||
{
|
||||
get
|
||||
|
@ -32,6 +32,13 @@ namespace SqlSugar
|
||||
exp = expression;
|
||||
type = typeof(T);
|
||||
}
|
||||
|
||||
public TableFilterItem(Type entityType,Expression expression)
|
||||
{
|
||||
exp = expression;
|
||||
type = entityType;
|
||||
}
|
||||
|
||||
private new string FilterName { get; set; }
|
||||
private new Func<ISqlSugarClient, SqlFilterResult> FilterValue { get; set; }
|
||||
private new bool IsJoinQuery { get; set; }
|
||||
|
15
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Enum/LanguageType.cs
Normal file
15
Src/Asp.NetCore2/SqlSeverTest/SqlSugar/Enum/LanguageType.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public enum LanguageType
|
||||
{
|
||||
Default=0,
|
||||
Chinese=1,
|
||||
English=2
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public interface ISplitTableService
|
||||
{
|
||||
List<SplitTableInfo> GetAllTables(ISqlSugarClient db,EntityInfo EntityInfo,List<DbTableInfo> tableInfos);
|
||||
string GetTableName(ISqlSugarClient db, EntityInfo EntityInfo);
|
||||
string GetTableName(ISqlSugarClient db, EntityInfo EntityInfo, SplitType type);
|
||||
string GetTableName(ISqlSugarClient db, EntityInfo entityInfo, SplitType splitType, object fieldValue);
|
||||
object GetFieldValue(ISqlSugarClient db, EntityInfo entityInfo, SplitType splitType, object entityValue);
|
||||
}
|
||||
}
|
@ -0,0 +1,259 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class DateSplitTableService : ISplitTableService
|
||||
{
|
||||
#region Core
|
||||
public virtual List<SplitTableInfo> GetAllTables(ISqlSugarClient db, EntityInfo EntityInfo, List<DbTableInfo> tableInfos)
|
||||
{
|
||||
CheckTableName(EntityInfo.DbTableName);
|
||||
var regex = EntityInfo.DbTableName.Replace("{year}", "([0-9]{2,4})").Replace("{day}", "([0-9]{1,2})").Replace("{month}", "([0-9]{1,2})");
|
||||
var currentTables = tableInfos.Where(it => Regex.IsMatch(it.Name, regex, RegexOptions.IgnoreCase)).Select(it => it.Name).Reverse().ToList();
|
||||
List<SplitTableInfo> result = new List<SplitTableInfo>();
|
||||
foreach (var item in currentTables)
|
||||
{
|
||||
SplitTableInfo tableInfo = new SplitTableInfo();
|
||||
tableInfo.TableName = item;
|
||||
var math = Regex.Match(item, regex,RegexOptions.IgnoreCase);
|
||||
var group1 = math.Groups[1].Value;
|
||||
var group2 = math.Groups[2].Value;
|
||||
var group3 = math.Groups[3].Value;
|
||||
tableInfo.Date = GetDate(group1, group2, group3, EntityInfo.DbTableName);
|
||||
//tableInfo.String = null; Time table, it doesn't work
|
||||
//tableInfo.Long = null; Time table, it doesn't work
|
||||
result.Add(tableInfo);
|
||||
}
|
||||
result = result.OrderByDescending(it => it.Date).ToList();
|
||||
return result;
|
||||
}
|
||||
public virtual string GetTableName(ISqlSugarClient db, EntityInfo EntityInfo)
|
||||
{
|
||||
var splitTableAttribute = EntityInfo.Type.GetCustomAttribute<SplitTableAttribute>();
|
||||
if (splitTableAttribute != null)
|
||||
{
|
||||
var type=(splitTableAttribute as SplitTableAttribute).SplitType;
|
||||
return GetTableName(db, EntityInfo, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetTableName(db, EntityInfo, SplitType.Day);
|
||||
}
|
||||
}
|
||||
public virtual string GetTableName(ISqlSugarClient db, EntityInfo EntityInfo, SplitType splitType)
|
||||
{
|
||||
var date = db.GetDate();
|
||||
return GetTableNameByDate(EntityInfo, splitType, date);
|
||||
}
|
||||
public virtual string GetTableName(ISqlSugarClient db, EntityInfo entityInfo, SplitType splitType, object fieldValue)
|
||||
{
|
||||
var value = Convert.ToDateTime(fieldValue);
|
||||
return GetTableNameByDate(entityInfo, splitType, value);
|
||||
}
|
||||
public virtual object GetFieldValue(ISqlSugarClient db, EntityInfo entityInfo, SplitType splitType, object entityValue)
|
||||
{
|
||||
var splitColumn = entityInfo.Columns.FirstOrDefault(it => it.PropertyInfo.GetCustomAttribute<SplitFieldAttribute>() != null);
|
||||
if (splitColumn == null)
|
||||
{
|
||||
return db.GetDate();
|
||||
}
|
||||
else
|
||||
{
|
||||
var value = splitColumn.PropertyInfo.GetValue(entityValue, null);
|
||||
if (value == null)
|
||||
{
|
||||
return db.GetDate();
|
||||
}
|
||||
else if (UtilMethods.GetUnderType(value.GetType()) != UtilConstants.DateType)
|
||||
{
|
||||
throw new Exception($"DateSplitTableService Split column {splitColumn.PropertyName} not DateTime " + splitType.ToString());
|
||||
}
|
||||
else if (Convert.ToDateTime(value) == DateTime.MinValue)
|
||||
{
|
||||
return db.GetDate();
|
||||
}
|
||||
else
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void VerifySplitType(SplitType splitType)
|
||||
{
|
||||
switch (splitType)
|
||||
{
|
||||
case SplitType.Day:
|
||||
break;
|
||||
case SplitType.Week:
|
||||
break;
|
||||
case SplitType.Month:
|
||||
break;
|
||||
case SplitType.Season:
|
||||
break;
|
||||
case SplitType.Year:
|
||||
break;
|
||||
default:
|
||||
throw new Exception("DateSplitTableService no support " + splitType.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Common Helper
|
||||
private string GetTableNameByDate(EntityInfo EntityInfo,SplitType splitType,DateTime date)
|
||||
{
|
||||
date = ConvertDateBySplitType(date, splitType);
|
||||
return EntityInfo.DbTableName.Replace("{year}", date.Year + "").Replace("{day}", PadLeft2(date.Day + "")).Replace("{month}", PadLeft2(date.Month + ""));
|
||||
}
|
||||
|
||||
private DateTime GetDate(string group1, string group2, string group3, string dbTableName)
|
||||
{
|
||||
var yearIndex = dbTableName.IndexOf("{year}");
|
||||
var dayIndex = dbTableName.IndexOf("{day}");
|
||||
var monthIndex = dbTableName.IndexOf("{month}");
|
||||
List<SplitTableSort> tables = new List<SplitTableSort>();
|
||||
tables.Add(new SplitTableSort() { Name = "{year}", Sort = yearIndex });
|
||||
tables.Add(new SplitTableSort() { Name = "{day}", Sort = dayIndex });
|
||||
tables.Add(new SplitTableSort() { Name = "{month}", Sort = monthIndex });
|
||||
tables = tables.OrderBy(it => it.Sort).ToList();
|
||||
var year = "";
|
||||
var month = "";
|
||||
var day = "";
|
||||
if (tables[0].Name == "{year}")
|
||||
{
|
||||
year = group1;
|
||||
}
|
||||
if (tables[1].Name == "{year}")
|
||||
{
|
||||
year = group2;
|
||||
}
|
||||
if (tables[2].Name == "{year}")
|
||||
{
|
||||
year = group3;
|
||||
}
|
||||
if (tables[0].Name == "{month}")
|
||||
{
|
||||
month = group1;
|
||||
}
|
||||
if (tables[1].Name == "{month}")
|
||||
{
|
||||
month = group2;
|
||||
}
|
||||
if (tables[2].Name == "{month}")
|
||||
{
|
||||
month = group3;
|
||||
}
|
||||
if (tables[0].Name == "{day}")
|
||||
{
|
||||
day = group1;
|
||||
}
|
||||
if (tables[1].Name == "{day}")
|
||||
{
|
||||
day = group2;
|
||||
}
|
||||
if (tables[2].Name == "{day}")
|
||||
{
|
||||
day = group3;
|
||||
}
|
||||
return Convert.ToDateTime($"{year}-{month}-{day}");
|
||||
}
|
||||
|
||||
private string PadLeft2(string str)
|
||||
{
|
||||
if (str.Length < 2)
|
||||
{
|
||||
return str.PadLeft(2, '0');
|
||||
}
|
||||
else
|
||||
{
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckTableName(string dbTableName)
|
||||
{
|
||||
Check.Exception(!dbTableName.Contains("{year}"), ErrorMessage.GetThrowMessage("table name need {{year}}", "分表表名需要占位符 {{year}}"));
|
||||
Check.Exception(!dbTableName.Contains("{month}"), ErrorMessage.GetThrowMessage("table name need {{month}}", "分表表名需要占位符 {{month}} "));
|
||||
Check.Exception(!dbTableName.Contains("{day}"), ErrorMessage.GetThrowMessage("table name need {{day}}", "分表表名需要占位符{{day}}"));
|
||||
Check.Exception(Regex.Matches(dbTableName, @"\{year\}").Count > 1, ErrorMessage.GetThrowMessage(" There can only be one {{year}}", " 只能有一个 {{year}}"));
|
||||
Check.Exception(Regex.Matches(dbTableName, @"\{month\}").Count > 1, ErrorMessage.GetThrowMessage("There can only be one {{month}}", "只能有一个 {{month}} "));
|
||||
Check.Exception(Regex.Matches(dbTableName, @"\{day\}").Count > 1, ErrorMessage.GetThrowMessage("There can only be one {{day}}", "只能有一个{{day}}"));
|
||||
Check.Exception(Regex.IsMatch(dbTableName, @"\d\{|\}\d"), ErrorMessage.GetThrowMessage(" '{{' or '}}' can't be numbers nearby", "占位符相令一位不能是数字,比如 : 1{{day}}2 错误 , 正确: 1_{{day}}_2"));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Date Helper
|
||||
private DateTime ConvertDateBySplitType(DateTime time, SplitType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SplitType.Day:
|
||||
return Convert.ToDateTime(time.ToString("yyyy-MM-dd"));
|
||||
case SplitType.Week:
|
||||
return GetMondayDate(time);
|
||||
case SplitType.Month:
|
||||
return Convert.ToDateTime(time.ToString("yyyy-MM-01"));
|
||||
case SplitType.Season:
|
||||
if (time.Month <= 3)
|
||||
{
|
||||
return Convert.ToDateTime(time.ToString("yyyy-01-01"));
|
||||
}
|
||||
else if (time.Month <= 6)
|
||||
{
|
||||
return Convert.ToDateTime(time.ToString("yyyy-04-01"));
|
||||
}
|
||||
else if (time.Month <= 9)
|
||||
{
|
||||
return Convert.ToDateTime(time.ToString("yyyy-07-01"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Convert.ToDateTime(time.ToString("yyyy-10-01"));
|
||||
}
|
||||
case SplitType.Year:
|
||||
return Convert.ToDateTime(time.ToString("yyyy-01-01"));
|
||||
default:
|
||||
throw new Exception($"SplitType paramter error ");
|
||||
}
|
||||
}
|
||||
private DateTime GetMondayDate()
|
||||
{
|
||||
return GetMondayDate(DateTime.Now);
|
||||
}
|
||||
private DateTime GetSundayDate()
|
||||
{
|
||||
return GetSundayDate(DateTime.Now);
|
||||
}
|
||||
private DateTime GetMondayDate(DateTime someDate)
|
||||
{
|
||||
int i = someDate.DayOfWeek - DayOfWeek.Monday;
|
||||
if (i == -1) i = 6;
|
||||
TimeSpan ts = new TimeSpan(i, 0, 0, 0);
|
||||
return someDate.Subtract(ts);
|
||||
}
|
||||
private DateTime GetSundayDate(DateTime someDate)
|
||||
{
|
||||
int i = someDate.DayOfWeek - DayOfWeek.Sunday;
|
||||
if (i != 0) i = 7 - i;
|
||||
TimeSpan ts = new TimeSpan(i, 0, 0, 0);
|
||||
return someDate.Add(ts);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Models
|
||||
internal class SplitTableSort
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Sort { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -17,5 +17,6 @@ namespace SqlSugar
|
||||
void InitTables<T, T2>();
|
||||
void InitTables<T, T2, T3>();
|
||||
void InitTables<T, T2, T3, T4>();
|
||||
SplitCodeFirstProvider SplitTables();
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ namespace SqlSugar
|
||||
IDeleteable<T> RemoveDataCache(string likeString);
|
||||
KeyValuePair<string, List<SugarParameter>> ToSql();
|
||||
IDeleteable<T> EnableQueryFilter();
|
||||
SplitTableDeleteProvider<T> SplitTable(Func<List<SplitTableInfo>, IEnumerable<SplitTableInfo>> getTableNamesFunc);
|
||||
void AddQueue();
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,9 @@ namespace SqlSugar
|
||||
ISugarQueryable<T> AS<T2>(string tableName);
|
||||
ISugarQueryable<T> AS(string tableName);
|
||||
ISugarQueryable<T> With(string withString);
|
||||
ISugarQueryable<T, T2> LeftJoin<T2>(ISugarQueryable<T2> joinQueryable, Expression<Func<T, T2, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2> InnerJoin<T2>(ISugarQueryable<T2> joinQueryable, Expression<Func<T, T2, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2> RightJoin<T2>(ISugarQueryable<T2> joinQueryable, Expression<Func<T, T2, bool>> joinExpression);
|
||||
ISugarQueryable<T,T2> LeftJoin<T2>(Expression<Func<T,T2,bool>> joinExpression);
|
||||
ISugarQueryable<T, T2> InnerJoin<T2>(Expression<Func<T, T2, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2> RightJoin<T2>(Expression<Func<T, T2, bool>> joinExpression);
|
||||
@ -179,9 +182,13 @@ namespace SqlSugar
|
||||
DataTable ToPivotTable<TColumn, TRow, TData>(Func<T, TColumn> columnSelector,Expression<Func<T, TRow>> rowSelector,Func<IEnumerable<T>, TData> dataSelector);
|
||||
List<dynamic> ToPivotList<TColumn, TRow, TData>(Func<T, TColumn> columnSelector, Expression<Func<T, TRow>> rowSelector, Func<IEnumerable<T>, TData> dataSelector);
|
||||
string ToPivotJson<TColumn, TRow, TData>(Func<T, TColumn> columnSelector, Expression<Func<T, TRow>> rowSelector, Func<IEnumerable<T>, TData> dataSelector);
|
||||
ISugarQueryable<T> SplitTable(Func<List<SplitTableInfo>,IEnumerable<SplitTableInfo>> getTableNamesFunc);
|
||||
}
|
||||
public partial interface ISugarQueryable<T, T2> : ISugarQueryable<T>
|
||||
{
|
||||
ISugarQueryable<T, T2,T3> LeftJoin<T3>(ISugarQueryable<T3> joinQueryable, Expression<Func<T, T2,T3, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2,T3> InnerJoin<T3>(ISugarQueryable<T3> joinQueryable, Expression<Func<T, T2,T3, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2,T3> RightJoin<T3>(ISugarQueryable<T3> joinQueryable, Expression<Func<T, T2,T3, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2,T3> LeftJoin<T3>(Expression<Func<T,T2,T3,bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3> InnerJoin<T3>(Expression<Func<T, T2, T3, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3> RightJoin<T3>(Expression<Func<T, T2, T3, bool>> joinExpression);
|
||||
@ -270,6 +277,9 @@ namespace SqlSugar
|
||||
}
|
||||
public partial interface ISugarQueryable<T, T2, T3> : ISugarQueryable<T>
|
||||
{
|
||||
ISugarQueryable<T, T2, T3,T4> LeftJoin<T4>(ISugarQueryable<T4> joinQueryable, Expression<Func<T, T2, T3,T4, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3,T4> InnerJoin<T4>(ISugarQueryable<T4> joinQueryable, Expression<Func<T, T2, T3,T4, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3,T4> RightJoin<T4>(ISugarQueryable<T4> joinQueryable, Expression<Func<T, T2, T3,T4, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3,T4> LeftJoin<T4>(Expression<Func<T, T2, T3,T4, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3,T4> InnerJoin<T4>(Expression<Func<T, T2, T3,T4, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4> RightJoin<T4>(Expression<Func<T, T2, T3, T4, bool>> joinExpression);
|
||||
@ -369,6 +379,9 @@ namespace SqlSugar
|
||||
}
|
||||
public partial interface ISugarQueryable<T, T2, T3, T4> : ISugarQueryable<T>
|
||||
{
|
||||
ISugarQueryable<T, T2, T3, T4, T5> LeftJoin<T5>(ISugarQueryable<T5> joinQueryable, Expression<Func<T, T2, T3, T4, T5, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5> InnerJoin<T5>(ISugarQueryable<T5> joinQueryable, Expression<Func<T, T2, T3, T4, T5, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5> RightJoin<T5>(ISugarQueryable<T5> joinQueryable, Expression<Func<T, T2, T3, T4, T5, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4,T5> LeftJoin<T5>(Expression<Func<T, T2, T3, T4,T5, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4,T5> InnerJoin<T5>(Expression<Func<T, T2, T3, T4,T5, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5> RightJoin<T5>(Expression<Func<T, T2, T3, T4, T5, bool>> joinExpression);
|
||||
@ -476,6 +489,9 @@ namespace SqlSugar
|
||||
}
|
||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5> : ISugarQueryable<T>
|
||||
{
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6> LeftJoin<T6>(ISugarQueryable<T6> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6> InnerJoin<T6>(ISugarQueryable<T6> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6> RightJoin<T6>(ISugarQueryable<T6> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5,T6> LeftJoin<T6>(Expression<Func<T, T2, T3, T4, T5,T6, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5,T6> InnerJoin<T6>(Expression<Func<T, T2, T3, T4, T5,T6, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6> RightJoin<T6>(Expression<Func<T, T2, T3, T4, T5, T6, bool>> joinExpression);
|
||||
@ -579,6 +595,9 @@ namespace SqlSugar
|
||||
}
|
||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6> : ISugarQueryable<T>
|
||||
{
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> LeftJoin<T7>(ISugarQueryable<T7> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> InnerJoin<T7>(ISugarQueryable<T7> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> RightJoin<T7>(ISugarQueryable<T7> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6,T7> LeftJoin<T7>(Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6,T7> InnerJoin<T7>(Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> RightJoin<T7>(Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> joinExpression);
|
||||
@ -689,6 +708,9 @@ namespace SqlSugar
|
||||
}
|
||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7> : ISugarQueryable<T>
|
||||
{
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> LeftJoin<T8>(ISugarQueryable<T8> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> InnerJoin<T8>(ISugarQueryable<T8> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> RightJoin<T8>(ISugarQueryable<T8> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> LeftJoin<T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> InnerJoin<T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> RightJoin<T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> joinExpression);
|
||||
@ -798,6 +820,9 @@ namespace SqlSugar
|
||||
}
|
||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> : ISugarQueryable<T>
|
||||
{
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> LeftJoin<T9>(ISugarQueryable<T9> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> InnerJoin<T9>(ISugarQueryable<T9> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> RightJoin<T9>(ISugarQueryable<T9> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> LeftJoin<T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> InnerJoin<T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> RightJoin<T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> joinExpression);
|
||||
@ -915,6 +940,9 @@ namespace SqlSugar
|
||||
#region 9-12
|
||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> : ISugarQueryable<T>
|
||||
{
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> LeftJoin<T10>(ISugarQueryable<T10> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> InnerJoin<T10>(ISugarQueryable<T10> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> RightJoin<T10>(ISugarQueryable<T10> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> LeftJoin<T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> InnerJoin<T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> RightJoin<T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> joinExpression);
|
||||
@ -966,6 +994,16 @@ namespace SqlSugar
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
|
||||
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
#endregion
|
||||
|
||||
#region GroupBy
|
||||
@ -1010,6 +1048,9 @@ namespace SqlSugar
|
||||
}
|
||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> : ISugarQueryable<T>
|
||||
{
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> LeftJoin<T11>(ISugarQueryable<T11> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> InnerJoin<T11>(ISugarQueryable<T11> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> RightJoin<T11>(ISugarQueryable<T11> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> LeftJoin<T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> InnerJoin<T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> RightJoin<T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> joinExpression);
|
||||
@ -1065,6 +1106,19 @@ namespace SqlSugar
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
|
||||
|
||||
|
||||
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
#endregion
|
||||
|
||||
#region GroupBy
|
||||
@ -1110,6 +1164,9 @@ namespace SqlSugar
|
||||
}
|
||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> : ISugarQueryable<T>
|
||||
{
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> LeftJoin<T12>(ISugarQueryable<T12> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> InnerJoin<T12>(ISugarQueryable<T12> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> RightJoin<T12>(ISugarQueryable<T12> joinQueryable, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> LeftJoin<T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> InnerJoin<T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, bool>> joinExpression);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> RightJoin<T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> joinExpression);
|
||||
@ -1169,6 +1226,18 @@ namespace SqlSugar
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
|
||||
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
#endregion
|
||||
|
||||
#region GroupBy
|
||||
@ -1275,6 +1344,19 @@ namespace SqlSugar
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderBy(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
|
||||
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> OrderByIF(bool isOrderBy, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, object>> expression, OrderByType type = OrderByType.Asc);
|
||||
#endregion
|
||||
|
||||
#region GroupBy
|
||||
|
@ -43,6 +43,9 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Other methods
|
||||
SplitTableContext SplitHelper<T>() where T : class, new();
|
||||
SplitTableContextResult<T> SplitHelper<T>(T data) where T : class, new();
|
||||
SplitTableContextResult<T> SplitHelper<T>(List<T> data) where T : class, new();
|
||||
DateTime GetDate();
|
||||
//SimpleClient GetSimpleClient();
|
||||
SimpleClient<T> GetSimpleClient<T>() where T : class, new();
|
||||
|
@ -92,6 +92,7 @@ namespace SqlSugar
|
||||
IUpdateable<T> CallEntityMethod(Expression<Action<T>> method);
|
||||
KeyValuePair<string,List<SugarParameter>> ToSql();
|
||||
void AddQueue();
|
||||
|
||||
SplitTableUpdateProvider<T> SplitTable(Func<List<SplitTableInfo>, IEnumerable<SplitTableInfo>> getTableNamesFunc);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public partial interface IInsertable<T>
|
||||
public partial interface IInsertable<T> where T :class,new()
|
||||
{
|
||||
InsertBuilder InsertBuilder { get; set; }
|
||||
int ExecuteCommand();
|
||||
@ -45,6 +45,9 @@ namespace SqlSugar
|
||||
SqlServerBlukCopy UseSqlServer();
|
||||
MySqlBlukCopy<T> UseMySql();
|
||||
OracleBlukCopy UseOracle();
|
||||
|
||||
SplitInsertable<T> SplitTable();
|
||||
SplitInsertable<T> SplitTable(SplitType splitType);
|
||||
void AddQueue();
|
||||
|
||||
}
|
||||
|
@ -42,10 +42,10 @@ namespace SqlSugar
|
||||
Type type = typeof(T);
|
||||
var entity = this.Context.EntityMaintenance.GetEntityInfo<T>();
|
||||
dt.TableName = this.Builder.GetTranslationColumnName(entity.DbTableName);
|
||||
if (this.Context.MappingTables != null && this.Context.MappingTables.Any(it => it.EntityName == it.EntityName))
|
||||
{
|
||||
dt.TableName = this.Builder.GetTranslationColumnName(this.Context.MappingTables.First(it => it.EntityName == it.EntityName).DbTableName);
|
||||
}
|
||||
//if (this.Context.MappingTables != null && this.Context.MappingTables.Any(it => it.EntityName == it.EntityName))
|
||||
//{
|
||||
// dt.TableName = this.Builder.GetTranslationColumnName(this.Context.MappingTables.First(it => it.EntityName == it.EntityName).DbTableName);
|
||||
//}
|
||||
//创建属性的集合
|
||||
List<PropertyInfo> pList = new List<PropertyInfo>();
|
||||
//把所有的public属性加入到集合 并添加DataTable的列
|
||||
|
@ -14,7 +14,7 @@ namespace SqlSugar
|
||||
Check.Exception(entityInfo.Columns.Where(it => it.IsPrimarykey).Count() > 1, "Use Code First ,The primary key must not exceed 1");
|
||||
|
||||
var tableName = GetTableName(entityInfo);
|
||||
var dbColumns = this.Context.DbMaintenance.GetColumnInfosByTableName(tableName);
|
||||
var dbColumns = this.Context.DbMaintenance.GetColumnInfosByTableName(tableName,false);
|
||||
ConvertColumns(dbColumns);
|
||||
var entityColumns = entityInfo.Columns.Where(it => it.IsIgnore == false).ToList();
|
||||
var dropColumns = dbColumns
|
||||
|
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
|
||||
public class SplitTableAttribute : Attribute
|
||||
{
|
||||
public SplitType SplitType { get; set; }
|
||||
public SplitTableAttribute(SplitType splitType)
|
||||
{
|
||||
this.SplitType = splitType;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property, Inherited = true)]
|
||||
public class SplitFieldAttribute : Attribute
|
||||
{
|
||||
|
||||
public SplitFieldAttribute()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class SplitTableContextResult<T>
|
||||
{
|
||||
public List<T> Items { get; set; }
|
||||
public SplitTableContext Helper { get; set; }
|
||||
|
||||
public string [] GetTableNames()
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
var attribute = typeof(T).GetCustomAttribute<SplitTableAttribute>() as SplitTableAttribute;
|
||||
Check.Exception(attribute == null, $" {typeof(T).Name} need SplitTableAttribute");
|
||||
foreach (var item in Items)
|
||||
{
|
||||
result.Add(Helper.GetTableName(Helper.GetValue(attribute.SplitType,item)));
|
||||
}
|
||||
return result.Distinct().ToArray();
|
||||
}
|
||||
public string[] GetTableNames(SplitType splitType)
|
||||
{
|
||||
List<string> result = new List<string>();;
|
||||
foreach (var item in Items)
|
||||
{
|
||||
result.Add(Helper.GetTableName(Helper.GetValue(splitType, item)));
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
}
|
||||
public class SplitTableContext
|
||||
{
|
||||
internal SqlSugarProvider Context { get; set; }
|
||||
internal EntityInfo EntityInfo { get; set; }
|
||||
internal ISplitTableService Service { get; set; }
|
||||
private SplitTableContext() { }
|
||||
internal SplitTableContext(SqlSugarProvider context)
|
||||
{
|
||||
this.Context = context;
|
||||
if (this.Context.CurrentConnectionConfig.ConfigureExternalServices != null&&this.Context.CurrentConnectionConfig.ConfigureExternalServices.SplitTableService!=null)
|
||||
{
|
||||
Service = this.Context.CurrentConnectionConfig.ConfigureExternalServices.SplitTableService;
|
||||
}
|
||||
else
|
||||
{
|
||||
Service = new DateSplitTableService();
|
||||
}
|
||||
}
|
||||
public List<SplitTableInfo> GetTables()
|
||||
{
|
||||
var oldIsEnableLogEvent = this.Context.Ado.IsEnableLogEvent;
|
||||
this.Context.Ado.IsEnableLogEvent = false;
|
||||
var tableInfos = this.Context.DbMaintenance.GetTableInfoList(false);
|
||||
List<SplitTableInfo> result = Service.GetAllTables(this.Context,EntityInfo,tableInfos);
|
||||
this.Context.Ado.IsEnableLogEvent = oldIsEnableLogEvent;
|
||||
return result;
|
||||
}
|
||||
|
||||
public string GetDefaultTableName()
|
||||
{
|
||||
return Service.GetTableName(this.Context,EntityInfo);
|
||||
}
|
||||
public string GetTableName(SplitType splitType)
|
||||
{
|
||||
return Service.GetTableName(this.Context,EntityInfo, splitType);
|
||||
}
|
||||
public string GetTableName(SplitType splitType, object fieldValue)
|
||||
{
|
||||
return Service.GetTableName(this.Context,EntityInfo, splitType, fieldValue);
|
||||
}
|
||||
public string GetTableName(object fieldValue)
|
||||
{
|
||||
var attribute = EntityInfo.Type.GetCustomAttribute<SplitTableAttribute>() as SplitTableAttribute;
|
||||
Check.Exception(attribute == null, $" {EntityInfo.EntityName} need SplitTableAttribute");
|
||||
return Service.GetTableName(this.Context, EntityInfo, attribute.SplitType, fieldValue);
|
||||
}
|
||||
public object GetValue(SplitType splitType, object entityValue)
|
||||
{
|
||||
return Service.GetFieldValue(this.Context,EntityInfo, splitType, entityValue);
|
||||
}
|
||||
internal void CheckPrimaryKey()
|
||||
{
|
||||
Check.Exception(EntityInfo.Columns.Any(it => it.IsIdentity == true), ErrorMessage.GetThrowMessage("Split table can't IsIdentity=true", "分表禁止使用自增列"));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class SplitTableInfo
|
||||
{
|
||||
public string TableName { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public String String { get; set; }
|
||||
public decimal Decimal { get; set; }
|
||||
public long Long { get; set; }
|
||||
public int Int { get; set; }
|
||||
public Byte[] ByteArray { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public enum SplitType
|
||||
{
|
||||
Day = 0,
|
||||
Week = 1,
|
||||
Month = 2,
|
||||
Season = 3,
|
||||
Year = 4,
|
||||
_Custom01 = 5,
|
||||
_Custom02 = 6,
|
||||
_Custom03 = 7,
|
||||
_Custom04 = 8,
|
||||
_Custom05 = 9,
|
||||
_Custom06 = 10,
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public static class SplitTableInfoExtensions
|
||||
{
|
||||
public static IEnumerable<SplitTableInfo> InTableNames(this List<SplitTableInfo> tables, params string[] tableNames)
|
||||
{
|
||||
return tables.Where(it => tableNames.Any(y => y.Equals(it.TableName, StringComparison.OrdinalIgnoreCase)));
|
||||
}
|
||||
public static IEnumerable<SplitTableInfo> ContainsTableNames(this List<SplitTableInfo> tables, params string[] tableNames)
|
||||
{
|
||||
List<SplitTableInfo> result = new List<SplitTableInfo>();
|
||||
foreach (var item in tables)
|
||||
{
|
||||
if (tableNames.Any(it => item.TableName.Contains(it)))
|
||||
{
|
||||
result.Add(item);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ namespace SqlSugar
|
||||
|
||||
public SqlSugarClient(List<ConnectionConfig> configs)
|
||||
{
|
||||
Check.Exception(configs.IsNullOrEmpty(), "List<ConnectionConfig> configs is null");
|
||||
Check.Exception(configs.IsNullOrEmpty(), "List<ConnectionConfig> configs is null or count=0");
|
||||
InitConfigs(configs);
|
||||
var config = configs.First();
|
||||
InitContext(config);
|
||||
@ -846,21 +846,33 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Helper
|
||||
public SplitTableContext SplitHelper<T>() where T:class,new()
|
||||
{
|
||||
return this.Context.SplitHelper<T>();
|
||||
}
|
||||
public SplitTableContextResult<T> SplitHelper<T>(T data) where T : class, new()
|
||||
{
|
||||
return this.Context.SplitHelper(data);
|
||||
}
|
||||
public SplitTableContextResult<T> SplitHelper<T>(List<T> dataList) where T : class, new()
|
||||
{
|
||||
return this.Context.SplitHelper(dataList);
|
||||
}
|
||||
private SqlSugarProvider GetContext()
|
||||
{
|
||||
SqlSugarProvider result = null;
|
||||
if (IsSameThreadAndShard())
|
||||
{
|
||||
result = SameThreadAndShard();
|
||||
}
|
||||
else if (IsNoSameThreadAndShard())
|
||||
{
|
||||
result = NoSameThreadAndShard();
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (IsSameThreadAndShard())
|
||||
//{
|
||||
// result = SameThreadAndShard();
|
||||
//}
|
||||
//else if (IsNoSameThreadAndShard())
|
||||
//{
|
||||
// result = NoSameThreadAndShard();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
result = Synchronization();
|
||||
}
|
||||
//}
|
||||
///Because SqlSugarScope implements thread safety
|
||||
//else if (IsSingleInstanceAsync())
|
||||
//{
|
||||
@ -1003,15 +1015,15 @@ namespace SqlSugar
|
||||
return _ThreadId == Thread.CurrentThread.ManagedThreadId.ToString();
|
||||
}
|
||||
|
||||
private bool IsNoSameThreadAndShard()
|
||||
{
|
||||
return CurrentConnectionConfig.IsShardSameThread && _ThreadId != Thread.CurrentThread.ManagedThreadId.ToString();
|
||||
}
|
||||
//private bool IsNoSameThreadAndShard()
|
||||
//{
|
||||
// return CurrentConnectionConfig.IsShardSameThread && _ThreadId != Thread.CurrentThread.ManagedThreadId.ToString();
|
||||
//}
|
||||
|
||||
private bool IsSameThreadAndShard()
|
||||
{
|
||||
return CurrentConnectionConfig.IsShardSameThread && _ThreadId == Thread.CurrentThread.ManagedThreadId.ToString();
|
||||
}
|
||||
//private bool IsSameThreadAndShard()
|
||||
//{
|
||||
// return CurrentConnectionConfig.IsShardSameThread && _ThreadId == Thread.CurrentThread.ManagedThreadId.ToString();
|
||||
//}
|
||||
|
||||
private SqlSugarProvider CopyClient()
|
||||
{
|
||||
@ -1051,7 +1063,7 @@ namespace SqlSugar
|
||||
_Context.Ado.IsEnableLogEvent = true;
|
||||
this.CurrentConnectionConfig = config;
|
||||
_ThreadId = Thread.CurrentThread.ManagedThreadId.ToString();
|
||||
if (_MappingColumns == null)
|
||||
if (this.MappingTables == null)
|
||||
this.MappingTables = new MappingTableList();
|
||||
if (this.MappingColumns == null)
|
||||
this.MappingColumns = new MappingColumnList();
|
||||
|
@ -596,6 +596,18 @@ namespace SqlSugar
|
||||
{
|
||||
return ScopedContext.Updateable(UpdateObjs);
|
||||
}
|
||||
public SplitTableContext SplitHelper<T>() where T : class, new()
|
||||
{
|
||||
return ScopedContext.SplitHelper<T>();
|
||||
}
|
||||
public SplitTableContextResult<T> SplitHelper<T>(T data) where T : class, new()
|
||||
{
|
||||
return ScopedContext.SplitHelper(data);
|
||||
}
|
||||
public SplitTableContextResult<T> SplitHelper<T>(List<T> dataList) where T : class, new()
|
||||
{
|
||||
return ScopedContext.SplitHelper(dataList);
|
||||
}
|
||||
public SqlSguarTransaction UseTran()
|
||||
{
|
||||
return ScopedContext.UseTran();
|
||||
|
@ -6,6 +6,7 @@ namespace SqlSugar
|
||||
{
|
||||
internal static partial class ErrorMessage
|
||||
{
|
||||
internal static LanguageType SugarLanguageType { get; set; } = LanguageType.Default;
|
||||
internal static string ObjNotExist
|
||||
{
|
||||
get
|
||||
@ -43,10 +44,21 @@ namespace SqlSugar
|
||||
|
||||
internal static string GetThrowMessage(string enMessage, string cnMessage, params string[] args)
|
||||
{
|
||||
List<string> formatArgs = new List<string>() { enMessage, cnMessage };
|
||||
formatArgs.AddRange(args);
|
||||
return string.Format(@"中文提示 : {1}
|
||||
Chinese Message : {0}", formatArgs.ToArray());
|
||||
if (SugarLanguageType == LanguageType.Default)
|
||||
{
|
||||
List<string> formatArgs = new List<string>() { enMessage, cnMessage };
|
||||
formatArgs.AddRange(args);
|
||||
return string.Format(@"中文提示 : {1}
|
||||
English Message : {0}", formatArgs.ToArray());
|
||||
}
|
||||
else if (SugarLanguageType == LanguageType.English)
|
||||
{
|
||||
return enMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
return cnMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user