Browse Source

Synchronization code

pull/32/head
sunkaixuan 2 years ago
parent
commit
702e4dc074
  1. 16
      Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarAccessory.cs
  2. 4
      Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs
  3. 7
      Src/Asp.Net/SqlSugar/Infrastructure/StaticConfig.cs

16
Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarAccessory.cs

@ -272,6 +272,10 @@ namespace SqlSugar
result.SqlBuilder.QueryBuilder.EntityType = typeof(T); result.SqlBuilder.QueryBuilder.EntityType = typeof(T);
result.SqlBuilder.QueryBuilder.EntityName = typeof(T).Name; result.SqlBuilder.QueryBuilder.EntityName = typeof(T).Name;
result.SqlBuilder.QueryBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(CurrentConnectionConfig); result.SqlBuilder.QueryBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(CurrentConnectionConfig);
if (StaticConfig.CompleteQueryableFunc != null)
{
StaticConfig.CompleteQueryableFunc(result);
}
return result; return result;
} }
protected InsertableProvider<T> CreateInsertable<T>(T[] insertObjs) where T : class, new() protected InsertableProvider<T> CreateInsertable<T>(T[] insertObjs) where T : class, new()
@ -288,6 +292,10 @@ namespace SqlSugar
sqlBuilder.InsertBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.CurrentConnectionConfig); sqlBuilder.InsertBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.CurrentConnectionConfig);
sqlBuilder.Context = result.SqlBuilder.InsertBuilder.Context = this; sqlBuilder.Context = result.SqlBuilder.InsertBuilder.Context = this;
result.Init(); result.Init();
if (StaticConfig.CompleteInsertableFunc != null)
{
StaticConfig.CompleteInsertableFunc(result);
}
return result; return result;
} }
protected DeleteableProvider<T> CreateDeleteable<T>() where T : class, new() protected DeleteableProvider<T> CreateDeleteable<T>() where T : class, new()
@ -301,6 +309,10 @@ namespace SqlSugar
sqlBuilder.DeleteBuilder.Builder = sqlBuilder; sqlBuilder.DeleteBuilder.Builder = sqlBuilder;
sqlBuilder.DeleteBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.CurrentConnectionConfig); sqlBuilder.DeleteBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.CurrentConnectionConfig);
sqlBuilder.Context = result.SqlBuilder.DeleteBuilder.Context = this; sqlBuilder.Context = result.SqlBuilder.DeleteBuilder.Context = this;
if (StaticConfig.CompleteDeleteableFunc != null)
{
StaticConfig.CompleteDeleteableFunc(result);
}
return result; return result;
} }
protected UpdateableProvider<T> CreateUpdateable<T>(T[] UpdateObjs) where T : class, new() protected UpdateableProvider<T> CreateUpdateable<T>(T[] UpdateObjs) where T : class, new()
@ -317,6 +329,10 @@ namespace SqlSugar
sqlBuilder.UpdateBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.CurrentConnectionConfig); sqlBuilder.UpdateBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.CurrentConnectionConfig);
sqlBuilder.Context = result.SqlBuilder.UpdateBuilder.Context = this; sqlBuilder.Context = result.SqlBuilder.UpdateBuilder.Context = this;
result.Init(); result.Init();
if (StaticConfig.CompleteUpdateableFunc != null)
{
StaticConfig.CompleteUpdateableFunc(result);
}
return result; return result;
} }

4
Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs

@ -28,6 +28,10 @@ namespace SqlSugar
this.ContextID = Guid.NewGuid(); this.ContextID = Guid.NewGuid();
Check.ArgumentNullException(config, "config is null"); Check.ArgumentNullException(config, "config is null");
CheckDbDependency(config); CheckDbDependency(config);
if (StaticConfig.CompleteDbFunc != null)
{
StaticConfig.CompleteDbFunc(this);
}
} }
#endregion #endregion

7
Src/Asp.Net/SqlSugar/Infrastructure/StaticConfig.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text; using System.Text;
namespace SqlSugar namespace SqlSugar
@ -10,5 +11,11 @@ namespace SqlSugar
public static Func<string,string> Decode{ get; set; } public static Func<string,string> Decode{ get; set; }
public const string CodeFirst_BigString = "varcharmax,longtext,text,clob"; public const string CodeFirst_BigString = "varcharmax,longtext,text,clob";
public static Func<long> CustomSnowFlakeFunc; public static Func<long> CustomSnowFlakeFunc;
public static Action<object> CompleteQueryableFunc;
public static Action<object> CompleteInsertableFunc;
public static Action<object> CompleteUpdateableFunc;
public static Action<object> CompleteDeleteableFunc;
public static Action<ISqlSugarClient> CompleteDbFunc;
} }
} }

Loading…
Cancel
Save