From b1a1c3f487be5469a4bab0238af33d20a21f6eab Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Thu, 11 May 2023 19:24:49 +0800 Subject: [PATCH] DbLink support --- .../SqlSugar/Abstract/QueryableProvider/QueryableHelper.cs | 5 +++++ Src/Asp.Net/SqlSugar/Entities/ConnectionConfig.cs | 4 ++++ Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs | 1 + 3 files changed, 10 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableHelper.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableHelper.cs index 90714210a..7f7235fe0 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableHelper.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableHelper.cs @@ -1188,6 +1188,11 @@ namespace SqlSugar tableName = this.QueryBuilder.LambdaExpressions.DbMehtods.GetTableWithDataBase (this.QueryBuilder.Builder.GetTranslationColumnName(dbName), this.QueryBuilder.Builder.GetTranslationColumnName(tableName)); } + var dbLinkName = this.Context.CurrentConnectionConfig.DbLinkName; + if (dbLinkName.HasValue()) + { + tableName = dbLinkName+"."+this.QueryBuilder.Builder.GetTranslationColumnName(tableName); + } return tableName; } protected string AppendSelect(List entityColumnInfos,string sql, ReadOnlyCollection parameters, List columnsResult, int parameterIndex1) diff --git a/Src/Asp.Net/SqlSugar/Entities/ConnectionConfig.cs b/Src/Asp.Net/SqlSugar/Entities/ConnectionConfig.cs index b1bbf3141..549efd813 100644 --- a/Src/Asp.Net/SqlSugar/Entities/ConnectionConfig.cs +++ b/Src/Asp.Net/SqlSugar/Entities/ConnectionConfig.cs @@ -23,6 +23,10 @@ namespace SqlSugar /// public string ConnectionString { get; set; } /// + /// QueryableWithAttr queries go to DbLinkName, which is commonly used for cross-library queries + /// + public string DbLinkName { get; set; } + /// /// true does not need to close the connection /// public bool IsAutoCloseConnection { get; set; } diff --git a/Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs b/Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs index 6f148e868..82c5bc4b0 100644 --- a/Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs +++ b/Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs @@ -237,6 +237,7 @@ namespace SqlSugar }, ConnectionString = it.ConnectionString, DbType = it.DbType, + DbLinkName= it.DbLinkName, IndexSuffix = it.IndexSuffix, InitKeyType = it.InitKeyType, IsAutoCloseConnection = it.IsAutoCloseConnection,