|
|
@ -1,6 +1,7 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
@ -28,14 +29,31 @@ namespace SqlSugar |
|
|
|
} |
|
|
|
|
|
|
|
public SimpleClient<T> GetRepository<T>() where T : class, new() |
|
|
|
{ |
|
|
|
TenantAttribute tenantAttribute = typeof(T).GetCustomAttribute<TenantAttribute>(); |
|
|
|
if (tenantAttribute == null) |
|
|
|
{ |
|
|
|
return new SimpleClient<T>(Db); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return new SimpleClient<T>(Db.AsTenant().GetConnection(tenantAttribute.configId)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public RepositoryType GetMyRepository<RepositoryType>() where RepositoryType : ISugarRepository, new() |
|
|
|
{ |
|
|
|
var result = new RepositoryType(); |
|
|
|
var type = typeof(RepositoryType).GetGenericArguments()[0]; |
|
|
|
TenantAttribute tenantAttribute = type.GetCustomAttribute<TenantAttribute>(); |
|
|
|
if (tenantAttribute == null) |
|
|
|
{ |
|
|
|
result.Context = this.Db; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
result.Context = this.Db.AsTenant().GetConnection(tenantAttribute.configId); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|