Browse Source

Add Gobal Event

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

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

@ -272,6 +272,10 @@ namespace SqlSugar
result.SqlBuilder.QueryBuilder.EntityType = typeof(T);
result.SqlBuilder.QueryBuilder.EntityName = typeof(T).Name;
result.SqlBuilder.QueryBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(CurrentConnectionConfig);
if (StaticConfig.CompleteQueryableFunc != null)
{
StaticConfig.CompleteQueryableFunc(result);
}
return result;
}
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.Context = result.SqlBuilder.InsertBuilder.Context = this;
result.Init();
if (StaticConfig.CompleteInsertableFunc != null)
{
StaticConfig.CompleteInsertableFunc(result);
}
return result;
}
protected DeleteableProvider<T> CreateDeleteable<T>() where T : class, new()
@ -301,6 +309,10 @@ namespace SqlSugar
sqlBuilder.DeleteBuilder.Builder = sqlBuilder;
sqlBuilder.DeleteBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.CurrentConnectionConfig);
sqlBuilder.Context = result.SqlBuilder.DeleteBuilder.Context = this;
if (StaticConfig.CompleteDeleteableFunc != null)
{
StaticConfig.CompleteDeleteableFunc(result);
}
return result;
}
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.Context = result.SqlBuilder.UpdateBuilder.Context = this;
result.Init();
if (StaticConfig.CompleteUpdateableFunc != null)
{
StaticConfig.CompleteUpdateableFunc(result);
}
return result;
}

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

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

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

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
@ -10,5 +11,11 @@ namespace SqlSugar
public static Func<string,string> Decode{ get; set; }
public const string CodeFirst_BigString = "varcharmax,longtext,text,clob";
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