Browse Source

Synchronization code

pull/31/head
sunkaixuan 2 years ago
parent
commit
d436a3a34e
  1. 4
      Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableHelper.cs
  2. 8
      Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

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

@ -999,9 +999,9 @@ namespace SqlSugar
#endregion #endregion
#region Other #region Other
private string GetTableName(EntityColumnInfo navPkColumn, string tableName) private string GetTableName(EntityInfo entity, string tableName)
{ {
var attr = navPkColumn?.PropertyInfo?.PropertyType?.GetCustomAttribute<TenantAttribute>(); var attr = entity?.Type?.GetCustomAttribute<TenantAttribute>();
var configId = ((object)this.Context.CurrentConnectionConfig.ConfigId).ObjToString(); var configId = ((object)this.Context.CurrentConnectionConfig.ConfigId).ObjToString();
if (attr != null && configId != attr.configId.ObjToString()) if (attr != null && configId != attr.configId.ObjToString())
{ {

8
Src/Asp.NetCore2/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -42,7 +42,7 @@ namespace SqlSugar
this.QueryBuilder.TableShortName = mainShortName; this.QueryBuilder.TableShortName = mainShortName;
var onWhere = $"{shortName}.{navPkColumn.DbColumnName}={mainShortName}.{navColumn.DbColumnName}"; var onWhere = $"{shortName}.{navPkColumn.DbColumnName}={mainShortName}.{navColumn.DbColumnName}";
UtilMethods.IsNullReturnNew(this.Context.TempItems); UtilMethods.IsNullReturnNew(this.Context.TempItems);
this.AddJoinInfo(GetTableName(navPkColumn, navEntityInfo.DbTableName), shortName, onWhere, JoinType.Left); this.AddJoinInfo(GetTableName(navEntityInfo, navEntityInfo.DbTableName), shortName, onWhere, JoinType.Left);
return this; return this;
} }
public ISugarQueryable<T> IncludeInnerJoin(Expression<Func<T, object>> innerObjectExt) public ISugarQueryable<T> IncludeInnerJoin(Expression<Func<T, object>> innerObjectExt)
@ -57,7 +57,7 @@ namespace SqlSugar
this.QueryBuilder.TableShortName = mainShortName; this.QueryBuilder.TableShortName = mainShortName;
var onWhere = $"{shortName}.{navPkColumn.DbColumnName}={mainShortName}.{navColumn.DbColumnName}"; var onWhere = $"{shortName}.{navPkColumn.DbColumnName}={mainShortName}.{navColumn.DbColumnName}";
UtilMethods.IsNullReturnNew(this.Context.TempItems); UtilMethods.IsNullReturnNew(this.Context.TempItems);
this.AddJoinInfo(GetTableName(navPkColumn, navEntityInfo.DbTableName), shortName, onWhere, JoinType.Inner); this.AddJoinInfo(GetTableName(navEntityInfo, navEntityInfo.DbTableName), shortName, onWhere, JoinType.Inner);
return this; return this;
} }
public ISugarQueryable<T> IncludeFullJoin(Expression<Func<T, object>> fullObjectExp) public ISugarQueryable<T> IncludeFullJoin(Expression<Func<T, object>> fullObjectExp)
@ -72,7 +72,7 @@ namespace SqlSugar
this.QueryBuilder.TableShortName = mainShortName; this.QueryBuilder.TableShortName = mainShortName;
var onWhere = $"{shortName}.{navPkColumn.DbColumnName}={mainShortName}.{navColumn.DbColumnName}"; var onWhere = $"{shortName}.{navPkColumn.DbColumnName}={mainShortName}.{navColumn.DbColumnName}";
UtilMethods.IsNullReturnNew(this.Context.TempItems); UtilMethods.IsNullReturnNew(this.Context.TempItems);
this.AddJoinInfo(GetTableName(navPkColumn, navEntityInfo.DbTableName), shortName, onWhere, JoinType.Full); this.AddJoinInfo(GetTableName(navEntityInfo, navEntityInfo.DbTableName), shortName, onWhere, JoinType.Full);
return this; return this;
} }
public ISugarQueryable<T> IncludeRightJoin(Expression<Func<T, object>> rightObjectExp) public ISugarQueryable<T> IncludeRightJoin(Expression<Func<T, object>> rightObjectExp)
@ -87,7 +87,7 @@ namespace SqlSugar
this.QueryBuilder.TableShortName = mainShortName; this.QueryBuilder.TableShortName = mainShortName;
var onWhere = $"{shortName}.{navPkColumn.DbColumnName}={mainShortName}.{navColumn.DbColumnName}"; var onWhere = $"{shortName}.{navPkColumn.DbColumnName}={mainShortName}.{navColumn.DbColumnName}";
UtilMethods.IsNullReturnNew(this.Context.TempItems); UtilMethods.IsNullReturnNew(this.Context.TempItems);
this.AddJoinInfo(GetTableName(navPkColumn, navEntityInfo.DbTableName), shortName, onWhere, JoinType.Right); this.AddJoinInfo(GetTableName(navEntityInfo, navEntityInfo.DbTableName), shortName, onWhere, JoinType.Right);
return this; return this;
} }

Loading…
Cancel
Save