mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-09 02:44:58 +08:00
Update core
This commit is contained in:
@@ -21,6 +21,7 @@ namespace SqlSugar
|
|||||||
Task<DbResult<T>> UseTranAsync<T>(Func<Task<T>> action, Action<Exception> errorCallBack = null);
|
Task<DbResult<T>> UseTranAsync<T>(Func<Task<T>> action, Action<Exception> errorCallBack = null);
|
||||||
void AddConnection(ConnectionConfig connection);
|
void AddConnection(ConnectionConfig connection);
|
||||||
SqlSugarProvider GetConnection(dynamic configId);
|
SqlSugarProvider GetConnection(dynamic configId);
|
||||||
|
SqlSugarProvider GetConnectionWithAttr<T>();
|
||||||
bool IsAnyConnection(dynamic configId);
|
bool IsAnyConnection(dynamic configId);
|
||||||
|
|
||||||
void Close();
|
void Close();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Diagnostics;
|
|||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -633,6 +634,13 @@ namespace SqlSugar
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public SqlSugarProvider GetConnectionWithAttr<T>()
|
||||||
|
{
|
||||||
|
var attr = typeof(T).GetCustomAttribute<TenantAttribute>();
|
||||||
|
Check.ExceptionEasy(attr==null,"not TenantAttribute", "不存在特性 TenantAttribute");
|
||||||
|
var configId = attr.configId;
|
||||||
|
return this.GetConnection(configId);
|
||||||
|
}
|
||||||
public SqlSugarProvider GetConnection(dynamic configId)
|
public SqlSugarProvider GetConnection(dynamic configId)
|
||||||
{
|
{
|
||||||
InitTenant();
|
InitTenant();
|
||||||
|
|||||||
@@ -158,6 +158,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return ScopedContext.GetConnection(configId);
|
return ScopedContext.GetConnection(configId);
|
||||||
}
|
}
|
||||||
|
public SqlSugarProvider GetConnectionWithAttr<T>()
|
||||||
|
{
|
||||||
|
return ScopedContext.GetConnectionWithAttr<T>();
|
||||||
|
}
|
||||||
|
|
||||||
public DateTime GetDate()
|
public DateTime GetDate()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,5 +29,14 @@ namespace SqlSugar
|
|||||||
if (isException)
|
if (isException)
|
||||||
throw new SqlSugarException(string.Format(message, args));
|
throw new SqlSugarException(string.Format(message, args));
|
||||||
}
|
}
|
||||||
|
public static void ExceptionEasy(string enMessage, string cnMessage)
|
||||||
|
{
|
||||||
|
throw new SqlSugarException(ErrorMessage.GetThrowMessage(enMessage, cnMessage));
|
||||||
|
}
|
||||||
|
public static void ExceptionEasy(bool isException, string enMessage, string cnMessage)
|
||||||
|
{
|
||||||
|
if (isException)
|
||||||
|
throw new SqlSugarException(ErrorMessage.GetThrowMessage(enMessage, cnMessage));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user