Browse Source

Modified multi-library entity AOP

pull/40/head
sunkaixuan 1 year ago
parent
commit
3bd36d2912
  1. 20
      Src/Asp.NetCore2/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs
  2. 2
      Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableHelper.cs
  3. 8
      Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs
  4. 10
      Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs
  5. 4
      Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider11-12.cs

20
Src/Asp.NetCore2/SqlSugar/Abstract/EntityMaintenance/EntityMaintenance.cs

@ -16,6 +16,26 @@ namespace SqlSugar
{
return GetEntityInfo(typeof(T));
}
public EntityInfo GetEntityInfoWithAttr(Type type)
{
var attr = type?.GetCustomAttribute<TenantAttribute>();
if (attr == null)
{
return GetEntityInfo(type);
}
else if (attr.configId.ObjToString() == this.Context?.CurrentConnectionConfig?.ConfigId+"")
{
return GetEntityInfo(type);
}
else if (this.Context.Root == null)
{
return GetEntityInfo(type);
}
else
{
return this.Context.Root.GetConnection(attr.configId).EntityMaintenance.GetEntityInfo(type);
}
}
public EntityInfo GetEntityInfo(Type type)
{
string cacheKey = "GetEntityInfo" + type.GetHashCode() + type.FullName+this.Context?.CurrentConnectionConfig?.ConfigId;

2
Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableHelper.cs

@ -1364,7 +1364,7 @@ namespace SqlSugar
protected string AppendSelect<EntityType>(string sql, ReadOnlyCollection<ParameterExpression> parameters, List<EntityColumnInfo> columnsResult, int parameterIndex1)
{
var columns = this.Context.EntityMaintenance.GetEntityInfo<EntityType>().Columns;
var columns = this.Context.EntityMaintenance.GetEntityInfoWithAttr(typeof(EntityType)).Columns;
var lowerSql = sql.ToLower();
var isSubquery = lowerSql.Contains("select ") && ExpressionTool.IsMemberInit(this.QueryBuilder.SelectValue);
if (isSubquery)

8
Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider02-05.cs

@ -260,7 +260,7 @@ namespace SqlSugar
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
sql = " ";
}
this.QueryBuilder.SubToListParameters = clone.QueryBuilder.SubToListParameters;
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
@ -973,7 +973,7 @@ namespace SqlSugar
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
sql = " ";
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.SubToListParameters = clone.QueryBuilder.SubToListParameters;
@ -1584,7 +1584,7 @@ namespace SqlSugar
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
sql = " ";
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.SubToListParameters = clone.QueryBuilder.SubToListParameters;
@ -2334,7 +2334,7 @@ namespace SqlSugar
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
sql = " ";
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.SubToListParameters = clone.QueryBuilder.SubToListParameters;

10
Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider06-10.cs

@ -316,7 +316,7 @@ namespace SqlSugar
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
sql = " ";
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.SubToListParameters = clone.QueryBuilder.SubToListParameters;
@ -1044,7 +1044,7 @@ namespace SqlSugar
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
sql = " ";
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.SubToListParameters = clone.QueryBuilder.SubToListParameters;
@ -1779,7 +1779,7 @@ namespace SqlSugar
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
sql = " ";
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.SubToListParameters = clone.QueryBuilder.SubToListParameters;
@ -2428,7 +2428,7 @@ namespace SqlSugar
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
sql = " ";
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.SubToListParameters = clone.QueryBuilder.SubToListParameters;
@ -3114,7 +3114,7 @@ namespace SqlSugar
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
sql = " ";
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.SubToListParameters = clone.QueryBuilder.SubToListParameters;

4
Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider11-12.cs

@ -306,7 +306,7 @@ namespace SqlSugar
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
sql = " ";
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.SubToListParameters = clone.QueryBuilder.SubToListParameters;
@ -895,7 +895,7 @@ namespace SqlSugar
var sql = clone.QueryBuilder.GetSelectValue;
if (this.QueryBuilder.IsSingle() || string.IsNullOrEmpty(sql) || sql.Trim() == "*")
{
return this.Select<TResult>(expression);
sql = " ";
}
this.QueryBuilder.Parameters = clone.QueryBuilder.Parameters;
this.QueryBuilder.SubToListParameters = clone.QueryBuilder.SubToListParameters;

Loading…
Cancel
Save