Crosss database query

This commit is contained in:
sunkaixuan
2022-10-06 11:21:50 +08:00
parent 7be5aa65e1
commit c1c74ff9da
2 changed files with 11 additions and 0 deletions

View File

@@ -719,6 +719,11 @@ namespace SqlSugar
return db; return db;
} }
} }
else if (this.CrossQueryItems!=null&& this.CrossQueryItems.Count>0&&this.CrossQueryItems.ContainsKey(type.FullName))
{
var result= db.Root.GetConnection(this.CrossQueryItems[type.FullName]);
return result;
}
else else
{ {
return db; return db;

View File

@@ -57,6 +57,12 @@ namespace SqlSugar
} }
public ISugarQueryable<T> CrossQuery(Type type, string configId) public ISugarQueryable<T> CrossQuery(Type type, string configId)
{ {
if (this.QueryBuilder.CrossQueryItems == null)
{
this.QueryBuilder.CrossQueryItems = new Dictionary<string, string>();
}
if(!this.QueryBuilder.CrossQueryItems.ContainsKey(type.FullName))
this.QueryBuilder.CrossQueryItems.Add(type.FullName, configId);
return this; return this;
} }
public ISugarQueryable<T> IncludeLeftJoin(Expression<Func<T, object>> LeftObject) public ISugarQueryable<T> IncludeLeftJoin(Expression<Func<T, object>> LeftObject)