Code optimization

This commit is contained in:
sunkaixuan 2017-09-06 10:13:29 +08:00
parent 632cd6c896
commit db2abc568d
20 changed files with 56 additions and 58 deletions

View File

@ -14,7 +14,7 @@ namespace OrmTest.Demo
db.Ado.IsEnableLogEvent = true; db.Ado.IsEnableLogEvent = true;
db.Ado.LogEventStarting = (sql, pars) => db.Ado.LogEventStarting = (sql, pars) =>
{ {
Console.WriteLine(sql + "\r\n" + db.RewritableMethods.SerializeObject(pars)); Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars));
Console.WriteLine(); Console.WriteLine();
}; };
return db; return db;

View File

@ -14,7 +14,7 @@ namespace OrmTest.Demo
db.Ado.IsEnableLogEvent = true; db.Ado.IsEnableLogEvent = true;
db.Ado.LogEventStarting = (sql, pars) => db.Ado.LogEventStarting = (sql, pars) =>
{ {
Console.WriteLine(sql + "\r\n" + db.RewritableMethods.SerializeObject(pars)); Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars));
Console.WriteLine(); Console.WriteLine();
}; };
return db; return db;

View File

@ -14,7 +14,7 @@ namespace OrmTest.Demo
db.Ado.IsEnableLogEvent = true; db.Ado.IsEnableLogEvent = true;
db.Ado.LogEventStarting = (sql, pars) => db.Ado.LogEventStarting = (sql, pars) =>
{ {
Console.WriteLine(sql + "\r\n" + db.RewritableMethods.SerializeObject(pars)); Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars));
Console.WriteLine(); Console.WriteLine();
}; };
return db; return db;

View File

@ -60,7 +60,7 @@ namespace OrmTest.UnitTest
db.Ado.IsEnableLogEvent = true; db.Ado.IsEnableLogEvent = true;
db.Ado.LogEventStarting = (sql, pars) => db.Ado.LogEventStarting = (sql, pars) =>
{ {
Console.WriteLine(sql + "\r\n" + db.RewritableMethods.SerializeObject(pars)); Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars));
Console.WriteLine(); Console.WriteLine();
}; };
return db; return db;

View File

@ -421,17 +421,17 @@ namespace SqlSugar
public virtual dynamic SqlQueryDynamic(string sql, object parameters = null) public virtual dynamic SqlQueryDynamic(string sql, object parameters = null)
{ {
var dt = this.GetDataTable(sql, parameters); var dt = this.GetDataTable(sql, parameters);
return dt == null ? null : this.Context.RewritableMethods.DataTableToDynamic(dt); return dt == null ? null : this.Context.Utilities.DataTableToDynamic(dt);
} }
public virtual dynamic SqlQueryDynamic(string sql, params SugarParameter[] parameters) public virtual dynamic SqlQueryDynamic(string sql, params SugarParameter[] parameters)
{ {
var dt = this.GetDataTable(sql, parameters); var dt = this.GetDataTable(sql, parameters);
return dt == null ? null : this.Context.RewritableMethods.DataTableToDynamic(dt); return dt == null ? null : this.Context.Utilities.DataTableToDynamic(dt);
} }
public dynamic SqlQueryDynamic(string sql, List<SugarParameter> parameters) public dynamic SqlQueryDynamic(string sql, List<SugarParameter> parameters)
{ {
var dt = this.GetDataTable(sql, parameters); var dt = this.GetDataTable(sql, parameters);
return dt == null ? null : this.Context.RewritableMethods.DataTableToDynamic(dt); return dt == null ? null : this.Context.Utilities.DataTableToDynamic(dt);
} }
public virtual DataTable GetDataTable(string sql, params SugarParameter[] parameters) public virtual DataTable GetDataTable(string sql, params SugarParameter[] parameters)
{ {
@ -536,7 +536,7 @@ namespace SqlSugar
} }
else else
{ {
action(sql, this.Context.RewritableMethods.SerializeObject(parameters.Select(it => new { key = it.ParameterName, value = it.Value.ObjToString() }))); action(sql, this.Context.Utilities.SerializeObject(parameters.Select(it => new { key = it.ParameterName, value = it.Value.ObjToString() })));
} }
} }
} }
@ -564,7 +564,7 @@ namespace SqlSugar
} }
else else
{ {
action(sql, this.Context.RewritableMethods.SerializeObject(parameters.Select(it => new { key = it.ParameterName, value = it.Value.ObjToString() }))); action(sql, this.Context.Utilities.SerializeObject(parameters.Select(it => new { key = it.ParameterName, value = it.Value.ObjToString() })));
} }
} }
} }

View File

@ -23,7 +23,7 @@ namespace SqlSugar
public virtual void InitTables(Type entityType) public virtual void InitTables(Type entityType)
{ {
this.Context.RewritableMethods.RemoveCacheAll(); this.Context.Utilities.RemoveCacheAll();
this.Context.InitMppingInfo(entityType); this.Context.InitMppingInfo(entityType);
if (!this.Context.DbMaintenance.IsAnySystemTablePermissions()) if (!this.Context.DbMaintenance.IsAnySystemTablePermissions())
{ {

View File

@ -10,7 +10,7 @@ namespace SqlSugar
protected List<T> GetEntityList<T>(SqlSugarClient context, IDataReader dataReader, string fields) protected List<T> GetEntityList<T>(SqlSugarClient context, IDataReader dataReader, string fields)
{ {
Type type = typeof(T); Type type = typeof(T);
var cacheManager = context.RewritableMethods.GetCacheInstance<IDataReaderEntityBuilder<T>>(); var cacheManager = context.Utilities.GetCacheInstance<IDataReaderEntityBuilder<T>>();
string key = "DataReaderToList." + fields + context.CurrentConnectionConfig.DbType + type.FullName; string key = "DataReaderToList." + fields + context.CurrentConnectionConfig.DbType + type.FullName;
IDataReaderEntityBuilder<T> entytyList = null; IDataReaderEntityBuilder<T> entytyList = null;
if (cacheManager.ContainsKey(key)) if (cacheManager.ContainsKey(key))

View File

@ -39,13 +39,13 @@ namespace SqlSugar
public void Init() public void Init()
{ {
this.Context.RewritableMethods.RemoveCacheAll(); this.Context.Utilities.RemoveCacheAll();
if (!this.Context.DbMaintenance.IsAnySystemTablePermissions()) if (!this.Context.DbMaintenance.IsAnySystemTablePermissions())
{ {
Check.Exception(true, "Dbfirst and Codefirst requires system table permissions"); Check.Exception(true, "Dbfirst and Codefirst requires system table permissions");
} }
this.TableInfoList = this.Context.RewritableMethods.TranslateCopy(this.Context.DbMaintenance.GetTableInfoList()); this.TableInfoList = this.Context.Utilities.TranslateCopy(this.Context.DbMaintenance.GetTableInfoList());
var viewList = this.Context.RewritableMethods.TranslateCopy(this.Context.DbMaintenance.GetViewInfoList()); var viewList = this.Context.Utilities.TranslateCopy(this.Context.DbMaintenance.GetViewInfoList());
if (viewList.IsValuable()) if (viewList.IsValuable())
{ {
this.TableInfoList.AddRange(viewList); this.TableInfoList.AddRange(viewList);

View File

@ -41,7 +41,7 @@ namespace SqlSugar
{ {
string cacheKey = "DbMaintenanceProvider.GetIsIdentities" + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); string cacheKey = "DbMaintenanceProvider.GetIsIdentities" + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
cacheKey = GetCacheKey(cacheKey); cacheKey = GetCacheKey(cacheKey);
return this.Context.RewritableMethods.GetCacheInstance<List<string>>().Func(cacheKey, return this.Context.Utilities.GetCacheInstance<List<string>>().Func(cacheKey,
(cm, key) => (cm, key) =>
{ {
return cm[cacheKey]; return cm[cacheKey];
@ -56,7 +56,7 @@ namespace SqlSugar
{ {
string cacheKey = "DbMaintenanceProvider.GetPrimaries" + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); string cacheKey = "DbMaintenanceProvider.GetPrimaries" + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
cacheKey = GetCacheKey(cacheKey); cacheKey = GetCacheKey(cacheKey);
return this.Context.RewritableMethods.GetCacheInstance<List<string>>().Func(cacheKey, return this.Context.Utilities.GetCacheInstance<List<string>>().Func(cacheKey,
(cm, key) => (cm, key) =>
{ {
return cm[cacheKey]; return cm[cacheKey];
@ -216,7 +216,7 @@ namespace SqlSugar
#region Private #region Private
private List<T> GetListOrCache<T>(string cacheKey, string sql) private List<T> GetListOrCache<T>(string cacheKey, string sql)
{ {
return this.Context.RewritableMethods.GetCacheInstance<List<T>>().Func(cacheKey, return this.Context.Utilities.GetCacheInstance<List<T>>().Func(cacheKey,
(cm, key) => (cm, key) =>
{ {
return cm[cacheKey]; return cm[cacheKey];

View File

@ -45,7 +45,7 @@ namespace SqlSugar
var entityName = typeof(T).Name; var entityName = typeof(T).Name;
IsAs = true; IsAs = true;
OldMappingTableList = this.Context.MappingTables; OldMappingTableList = this.Context.MappingTables;
this.Context.MappingTables = this.Context.RewritableMethods.TranslateCopy(this.Context.MappingTables); this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
this.Context.MappingTables.Add(entityName, tableName); this.Context.MappingTables.Add(entityName, tableName);
return this; ; return this; ;
} }
@ -249,7 +249,7 @@ namespace SqlSugar
} }
private IDeleteable<T> CopyDeleteable() { private IDeleteable<T> CopyDeleteable() {
var asyncContext = this.Context.CopyContext(this.Context.RewritableMethods.TranslateCopy(this.Context.CurrentConnectionConfig)); var asyncContext = this.Context.CopyContext(this.Context.Utilities.TranslateCopy(this.Context.CurrentConnectionConfig));
asyncContext.CurrentConnectionConfig.IsAutoCloseConnection = true; asyncContext.CurrentConnectionConfig.IsAutoCloseConnection = true;
asyncContext.Ado.IsEnableLogEvent = this.Context.Ado.IsEnableLogEvent; asyncContext.Ado.IsEnableLogEvent = this.Context.Ado.IsEnableLogEvent;
asyncContext.Ado.LogEventStarting = this.Context.Ado.LogEventStarting; asyncContext.Ado.LogEventStarting = this.Context.Ado.LogEventStarting;

View File

@ -18,7 +18,7 @@ namespace SqlSugar
public EntityInfo GetEntityInfo(Type type) public EntityInfo GetEntityInfo(Type type)
{ {
string cacheKey = "GetEntityInfo" + type.FullName; string cacheKey = "GetEntityInfo" + type.FullName;
return this.Context.RewritableMethods.GetCacheInstance<EntityInfo>().Func(cacheKey, return this.Context.Utilities.GetCacheInstance<EntityInfo>().Func(cacheKey,
(cm, key) => (cm, key) =>
{ {
return cm[cacheKey]; return cm[cacheKey];

View File

@ -140,7 +140,7 @@ namespace SqlSugar
var entityName = typeof(T).Name; var entityName = typeof(T).Name;
IsAs = true; IsAs = true;
OldMappingTableList = this.Context.MappingTables; OldMappingTableList = this.Context.MappingTables;
this.Context.MappingTables = this.Context.RewritableMethods.TranslateCopy(this.Context.MappingTables); this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
this.Context.MappingTables.Add(entityName, tableName); this.Context.MappingTables.Add(entityName, tableName);
return this; ; return this; ;
} }
@ -307,7 +307,7 @@ namespace SqlSugar
} }
private IInsertable<T> CopyInsertable() private IInsertable<T> CopyInsertable()
{ {
var asyncContext = this.Context.CopyContext(this.Context.RewritableMethods.TranslateCopy(this.Context.CurrentConnectionConfig)); var asyncContext = this.Context.CopyContext(this.Context.Utilities.TranslateCopy(this.Context.CurrentConnectionConfig));
asyncContext.CurrentConnectionConfig.IsAutoCloseConnection = true; asyncContext.CurrentConnectionConfig.IsAutoCloseConnection = true;
asyncContext.Ado.IsEnableLogEvent = this.Context.Ado.IsEnableLogEvent; asyncContext.Ado.IsEnableLogEvent = this.Context.Ado.IsEnableLogEvent;
asyncContext.Ado.LogEventStarting = this.Context.Ado.LogEventStarting; asyncContext.Ado.LogEventStarting = this.Context.Ado.LogEventStarting;

View File

@ -50,7 +50,7 @@ namespace SqlSugar
var entityName = typeof(T2).Name; var entityName = typeof(T2).Name;
IsAs = true; IsAs = true;
OldMappingTableList = this.Context.MappingTables; OldMappingTableList = this.Context.MappingTables;
this.Context.MappingTables = this.Context.RewritableMethods.TranslateCopy(this.Context.MappingTables); this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
this.Context.MappingTables.Add(entityName, tableName); this.Context.MappingTables.Add(entityName, tableName);
this.QueryableMappingTableList = this.Context.MappingTables; this.QueryableMappingTableList = this.Context.MappingTables;
return this; return this;
@ -60,7 +60,7 @@ namespace SqlSugar
var entityName = typeof(T).Name; var entityName = typeof(T).Name;
IsAs = true; IsAs = true;
OldMappingTableList = this.Context.MappingTables; OldMappingTableList = this.Context.MappingTables;
this.Context.MappingTables = this.Context.RewritableMethods.TranslateCopy(this.Context.MappingTables); this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
this.Context.MappingTables.Add(entityName, tableName); this.Context.MappingTables.Add(entityName, tableName);
this.QueryableMappingTableList = this.Context.MappingTables; this.QueryableMappingTableList = this.Context.MappingTables;
return this; return this;
@ -486,15 +486,15 @@ namespace SqlSugar
} }
public virtual string ToJson() public virtual string ToJson()
{ {
return this.Context.RewritableMethods.SerializeObject(this.ToList()); return this.Context.Utilities.SerializeObject(this.ToList());
} }
public virtual string ToJsonPage(int pageIndex, int pageSize) public virtual string ToJsonPage(int pageIndex, int pageSize)
{ {
return this.Context.RewritableMethods.SerializeObject(this.ToPageList(pageIndex, pageSize)); return this.Context.Utilities.SerializeObject(this.ToPageList(pageIndex, pageSize));
} }
public virtual string ToJsonPage(int pageIndex, int pageSize, ref int totalNumber) public virtual string ToJsonPage(int pageIndex, int pageSize, ref int totalNumber)
{ {
return this.Context.RewritableMethods.SerializeObject(this.ToPageList(pageIndex, pageSize, ref totalNumber)); return this.Context.Utilities.SerializeObject(this.ToPageList(pageIndex, pageSize, ref totalNumber));
} }
public virtual DataTable ToDataTable() public virtual DataTable ToDataTable()
@ -948,11 +948,11 @@ namespace SqlSugar
{ {
if (typeof(TResult) == typeof(ExpandoObject)) if (typeof(TResult) == typeof(ExpandoObject))
{ {
return this.Context.RewritableMethods.DataReaderToExpandoObjectList(dataReader) as List<TResult>; return this.Context.Utilities.DataReaderToExpandoObjectList(dataReader) as List<TResult>;
} }
if (entityType.IsAnonymousType() || isComplexModel) if (entityType.IsAnonymousType() || isComplexModel)
{ {
result = this.Context.RewritableMethods.DataReaderToDynamicList<TResult>(dataReader); result = this.Context.Utilities.DataReaderToDynamicList<TResult>(dataReader);
} }
else else
{ {
@ -1034,7 +1034,7 @@ namespace SqlSugar
} }
private ISugarQueryable<T> CopyQueryable() private ISugarQueryable<T> CopyQueryable()
{ {
var asyncContext = this.Context.CopyContext(this.Context.RewritableMethods.TranslateCopy(this.Context.CurrentConnectionConfig)); var asyncContext = this.Context.CopyContext(this.Context.Utilities.TranslateCopy(this.Context.CurrentConnectionConfig));
asyncContext.CurrentConnectionConfig.IsAutoCloseConnection = true; asyncContext.CurrentConnectionConfig.IsAutoCloseConnection = true;
asyncContext.Ado.IsEnableLogEvent = this.Context.Ado.IsEnableLogEvent; asyncContext.Ado.IsEnableLogEvent = this.Context.Ado.IsEnableLogEvent;
asyncContext.Ado.LogEventStarting = this.Context.Ado.LogEventStarting; asyncContext.Ado.LogEventStarting = this.Context.Ado.LogEventStarting;

View File

@ -48,7 +48,7 @@ namespace SqlSugar
var entityName = typeof(T).Name; var entityName = typeof(T).Name;
IsAs = true; IsAs = true;
OldMappingTableList = this.Context.MappingTables; OldMappingTableList = this.Context.MappingTables;
this.Context.MappingTables = this.Context.RewritableMethods.TranslateCopy(this.Context.MappingTables); this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
this.Context.MappingTables.Add(entityName, tableName); this.Context.MappingTables.Add(entityName, tableName);
return this; ; return this; ;
} }
@ -311,7 +311,7 @@ namespace SqlSugar
} }
private IUpdateable<T> CopyUpdateable() private IUpdateable<T> CopyUpdateable()
{ {
var asyncContext = this.Context.CopyContext(this.Context.RewritableMethods.TranslateCopy(this.Context.CurrentConnectionConfig)); var asyncContext = this.Context.CopyContext(this.Context.Utilities.TranslateCopy(this.Context.CurrentConnectionConfig));
asyncContext.CurrentConnectionConfig.IsAutoCloseConnection = true; asyncContext.CurrentConnectionConfig.IsAutoCloseConnection = true;
asyncContext.Ado.IsEnableLogEvent = this.Context.Ado.IsEnableLogEvent; asyncContext.Ado.IsEnableLogEvent = this.Context.Ado.IsEnableLogEvent;
asyncContext.Ado.LogEventStarting = this.Context.Ado.LogEventStarting; asyncContext.Ado.LogEventStarting = this.Context.Ado.LogEventStarting;

View File

@ -97,7 +97,7 @@ namespace SqlSugar
public void InitMppingInfo(Type type) public void InitMppingInfo(Type type)
{ {
string cacheKey = "Context.InitAttributeMappingTables" + type.FullName; string cacheKey = "Context.InitAttributeMappingTables" + type.FullName;
var entityInfo = this.Context.RewritableMethods.GetCacheInstance<EntityInfo>().Func(cacheKey, var entityInfo = this.Context.Utilities.GetCacheInstance<EntityInfo>().Func(cacheKey,
(cm, key) => (cm, key) =>
{ {
var cacheInfo = cm[key]; var cacheInfo = cm[key];

View File

@ -170,7 +170,7 @@ namespace SqlSugar
{ {
string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
cacheKey = GetCacheKey(cacheKey); cacheKey = GetCacheKey(cacheKey);
return this.Context.RewritableMethods.GetCacheInstance<List<DbColumnInfo>>().Func(cacheKey, return this.Context.Utilities.GetCacheInstance<List<DbColumnInfo>>().Func(cacheKey,
(cm, key) => (cm, key) =>
{ {
return cm[cacheKey]; return cm[cacheKey];
@ -211,7 +211,7 @@ namespace SqlSugar
{ {
string cacheKey = "DbMaintenanceProvider.GetPrimaryKeyByTableNames." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); string cacheKey = "DbMaintenanceProvider.GetPrimaryKeyByTableNames." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
cacheKey = GetCacheKey(cacheKey); cacheKey = GetCacheKey(cacheKey);
return this.Context.RewritableMethods.GetCacheInstance<List<string>>().Func(cacheKey, return this.Context.Utilities.GetCacheInstance<List<string>>().Func(cacheKey,
(cm, key) => (cm, key) =>
{ {
return cm[cacheKey]; return cm[cacheKey];

View File

@ -168,7 +168,7 @@ namespace SqlSugar
{ {
string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower(); string cacheKey = "DbMaintenanceProvider.GetColumnInfosByTableName." + this.SqlBuilder.GetNoTranslationColumnName(tableName).ToLower();
cacheKey = GetCacheKey(cacheKey); cacheKey = GetCacheKey(cacheKey);
return this.Context.RewritableMethods.GetCacheInstance<List<DbColumnInfo>>().Func(cacheKey, return this.Context.Utilities.GetCacheInstance<List<DbColumnInfo>>().Func(cacheKey,
(cm, key) => (cm, key) =>
{ {
return cm[cacheKey]; return cm[cacheKey];
@ -260,7 +260,7 @@ namespace SqlSugar
} }
private List<T> GetListOrCache<T>(string cacheKey, string sql) private List<T> GetListOrCache<T>(string cacheKey, string sql)
{ {
return this.Context.RewritableMethods.GetCacheInstance<List<T>>().Func(cacheKey, return this.Context.Utilities.GetCacheInstance<List<T>>().Func(cacheKey,
(cm, key) => (cm, key) =>
{ {
return cm[cacheKey]; return cm[cacheKey];

View File

@ -60,23 +60,21 @@ namespace SqlSugar
#endregion #endregion
#region Rewritable Methods #region Rewritable Methods
/// <summary> [Obsolete("db.IRewritableMethods is Obsolete,Use db.Utilities")]
/// Rewritable Methods
/// </summary>
public virtual IRewritableMethods RewritableMethods public virtual IRewritableMethods RewritableMethods
{
get { return this.Utilities; }
set { this.Utilities = value; }
}
public virtual IRewritableMethods Utilities
{ {
get get
{ {
if (base._RewritableMethods == null) if (base._RewritableMethods == null)
{
base._RewritableMethods = new RewritableMethods(); base._RewritableMethods = new RewritableMethods();
}
return _RewritableMethods; return _RewritableMethods;
} }
set set { base._RewritableMethods = value; }
{
base._RewritableMethods = value;
}
} }
#endregion #endregion
@ -152,7 +150,7 @@ namespace SqlSugar
} }
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Queryable<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, T7, object[]>> joinExpression) where T : class, new() public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Queryable<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, T7, object[]>> joinExpression) where T : class, new()
{ {
InitMppingInfo<T, T2, T3, T4, T5, T6,T7>(); InitMppingInfo<T, T2, T3, T4, T5, T6, T7>();
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7) }; var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7) };
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7>(base.CurrentConnectionConfig); var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7>(base.CurrentConnectionConfig);
base.CreateQueryJoin(joinExpression, types, queryable); base.CreateQueryJoin(joinExpression, types, queryable);
@ -160,7 +158,7 @@ namespace SqlSugar
} }
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Queryable<T, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object[]>> joinExpression) where T : class, new() public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> Queryable<T, T2, T3, T4, T5, T6, T7, T8>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, object[]>> joinExpression) where T : class, new()
{ {
InitMppingInfo<T, T2, T3, T4, T5, T6,T7, T8>(); InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8>();
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8) }; var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8) };
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(base.CurrentConnectionConfig); var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(base.CurrentConnectionConfig);
base.CreateQueryJoin(joinExpression, types, queryable); base.CreateQueryJoin(joinExpression, types, queryable);
@ -169,7 +167,7 @@ namespace SqlSugar
#region 9-12 #region 9-12
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object[]>> joinExpression) where T : class, new() public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, object[]>> joinExpression) where T : class, new()
{ {
InitMppingInfo<T, T2, T3, T4, T5, T6,T7, T8, T9>(); InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9>();
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9) }; var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9) };
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(base.CurrentConnectionConfig); var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(base.CurrentConnectionConfig);
base.CreateQueryJoin(joinExpression, types, queryable); base.CreateQueryJoin(joinExpression, types, queryable);
@ -177,7 +175,7 @@ namespace SqlSugar
} }
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object[]>> joinExpression) where T : class, new() public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, object[]>> joinExpression) where T : class, new()
{ {
InitMppingInfo<T, T2, T3, T4, T5, T6, T7,T8, T9, T10>(); InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>();
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10) }; var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10) };
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(base.CurrentConnectionConfig); var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(base.CurrentConnectionConfig);
base.CreateQueryJoin(joinExpression, types, queryable); base.CreateQueryJoin(joinExpression, types, queryable);
@ -185,7 +183,7 @@ namespace SqlSugar
} }
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object[]>> joinExpression) where T : class, new() public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, object[]>> joinExpression) where T : class, new()
{ {
InitMppingInfo<T, T2, T3, T4, T5, T6,T7, T8, T9, T10, T11>(); InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>();
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11) }; var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11) };
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(base.CurrentConnectionConfig); var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(base.CurrentConnectionConfig);
base.CreateQueryJoin(joinExpression, types, queryable); base.CreateQueryJoin(joinExpression, types, queryable);
@ -193,7 +191,7 @@ namespace SqlSugar
} }
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, object[]>> joinExpression) where T : class, new() public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, object[]>> joinExpression) where T : class, new()
{ {
InitMppingInfo<T, T2, T3, T4, T5, T6,T7, T8, T9, T10, T11, T12>(); InitMppingInfo<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>();
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11), typeof(T12) }; var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11), typeof(T12) };
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(base.CurrentConnectionConfig); var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(base.CurrentConnectionConfig);
base.CreateQueryJoin(joinExpression, types, queryable); base.CreateQueryJoin(joinExpression, types, queryable);
@ -352,7 +350,7 @@ namespace SqlSugar
{ {
InitMppingInfo<T>(); InitMppingInfo<T>();
Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Insertable.columnDictionary can't be null"); Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Insertable.columnDictionary can't be null");
var insertObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(columnDictionary)); var insertObject = this.Utilities.DeserializeObject<T>(this.Utilities.SerializeObject(columnDictionary));
var columns = columnDictionary.Select(it => it.Key).ToList(); var columns = columnDictionary.Select(it => it.Key).ToList();
return this.Insertable(insertObject).InsertColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ; return this.Insertable(insertObject).InsertColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ;
} }
@ -367,7 +365,7 @@ namespace SqlSugar
{ {
var columns = ((object)insertDynamicObject).GetType().GetProperties().Select(it => it.Name).ToList(); var columns = ((object)insertDynamicObject).GetType().GetProperties().Select(it => it.Name).ToList();
Check.Exception(columns.IsNullOrEmpty(), "Insertable.updateDynamicObject can't be null"); Check.Exception(columns.IsNullOrEmpty(), "Insertable.updateDynamicObject can't be null");
T insertObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(insertDynamicObject)); T insertObject = this.Utilities.DeserializeObject<T>(this.Utilities.SerializeObject(insertDynamicObject));
return this.Insertable(insertObject).InsertColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); return this.Insertable(insertObject).InsertColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase)));
} }
} }
@ -436,7 +434,7 @@ namespace SqlSugar
{ {
InitMppingInfo<T>(); InitMppingInfo<T>();
Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Updateable.columnDictionary can't be null"); Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Updateable.columnDictionary can't be null");
var updateObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(columnDictionary)); var updateObject = this.Utilities.DeserializeObject<T>(this.Utilities.SerializeObject(columnDictionary));
var columns = columnDictionary.Select(it => it.Key).ToList(); var columns = columnDictionary.Select(it => it.Key).ToList();
return this.Updateable(updateObject).UpdateColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ; return this.Updateable(updateObject).UpdateColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ;
} }
@ -451,7 +449,7 @@ namespace SqlSugar
{ {
var columns = ((object)updateDynamicObject).GetType().GetProperties().Select(it => it.Name).ToList(); var columns = ((object)updateDynamicObject).GetType().GetProperties().Select(it => it.Name).ToList();
Check.Exception(columns.IsNullOrEmpty(), "Updateable.updateDynamicObject can't be null"); Check.Exception(columns.IsNullOrEmpty(), "Updateable.updateDynamicObject can't be null");
T updateObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(updateDynamicObject)); T updateObject = this.Utilities.DeserializeObject<T>(this.Utilities.SerializeObject(updateDynamicObject));
return this.Updateable(updateObject).UpdateColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ; return this.Updateable(updateObject).UpdateColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ;
} }
} }

View File

@ -24,7 +24,7 @@ namespace SqlSugar
var parsStr = string.Empty; ; var parsStr = string.Empty; ;
if (pars != null) if (pars != null)
{ {
parsStr = context.RewritableMethods.SerializeObject(pars); parsStr = context.Utilities.SerializeObject(pars);
} }
var reval = GetLineMessage("message", message) + GetLineMessage("function", parsStr); var reval = GetLineMessage("message", message) + GetLineMessage("function", parsStr);
return reval; return reval;

View File

@ -14,7 +14,7 @@ namespace OrmTest.Demo
db.Ado.IsEnableLogEvent = true; db.Ado.IsEnableLogEvent = true;
db.Ado.LogEventStarting = (sql, pars) => db.Ado.LogEventStarting = (sql, pars) =>
{ {
Console.WriteLine(sql + "\r\n" + db.RewritableMethods.SerializeObject(pars)); Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars));
Console.WriteLine(); Console.WriteLine();
}; };
return db; return db;