mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-01 10:10:16 +08:00
Update Core
This commit is contained in:
parent
7df4d3d2a6
commit
019a919f44
@ -1373,15 +1373,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
protected ISugarQueryable<T> _As(string tableName, string entityName)
|
protected ISugarQueryable<T> _As(string tableName, string entityName)
|
||||||
{
|
{
|
||||||
IsAs = true;
|
this.QueryBuilder.AsTables.Add(entityName, tableName);
|
||||||
OldMappingTableList = this.Context.MappingTables;
|
|
||||||
this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
|
|
||||||
if (this.Context.MappingTables.Any(it => it.EntityName == entityName))
|
|
||||||
{
|
|
||||||
this.Context.MappingTables.Add(this.Context.MappingTables.First(it => it.EntityName == entityName).DbTableName, tableName);
|
|
||||||
}
|
|
||||||
this.Context.MappingTables.Add(entityName, tableName);
|
|
||||||
this.QueryableMappingTableList = this.Context.MappingTables;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
protected void _Filter(string FilterName, bool isDisabledGobalFilter)
|
protected void _Filter(string FilterName, bool isDisabledGobalFilter)
|
||||||
@ -2048,6 +2040,7 @@ namespace SqlSugar
|
|||||||
asyncQueryableBuilder.HavingInfos = this.QueryBuilder.HavingInfos;
|
asyncQueryableBuilder.HavingInfos = this.QueryBuilder.HavingInfos;
|
||||||
asyncQueryableBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
asyncQueryableBuilder.LambdaExpressions.ParameterIndex = this.QueryBuilder.LambdaExpressions.ParameterIndex;
|
||||||
asyncQueryableBuilder.IgnoreColumns = this.QueryBuilder.IgnoreColumns;
|
asyncQueryableBuilder.IgnoreColumns = this.QueryBuilder.IgnoreColumns;
|
||||||
|
asyncQueryableBuilder.AsTables = this.QueryBuilder.AsTables;
|
||||||
}
|
}
|
||||||
protected int SetCacheTime(int cacheDurationInSeconds)
|
protected int SetCacheTime(int cacheDurationInSeconds)
|
||||||
{
|
{
|
||||||
|
@ -114,6 +114,7 @@ namespace SqlSugar
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Sql Template
|
#region Sql Template
|
||||||
|
public Dictionary<string, string> AsTables=new Dictionary<string, string>();
|
||||||
public virtual string SqlTemplate
|
public virtual string SqlTemplate
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -357,10 +358,22 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public virtual string ToJoinString(JoinQueryInfo joinInfo)
|
public virtual string ToJoinString(JoinQueryInfo joinInfo)
|
||||||
{
|
{
|
||||||
|
var name = joinInfo.TableName;
|
||||||
|
if (this.AsTables.Any())
|
||||||
|
{
|
||||||
|
if (this.Context.MappingTables != null && this.Context.MappingTables.Any(it => it.DbTableName == name))
|
||||||
|
{
|
||||||
|
name = this.Context.MappingTables.First(it => it.DbTableName == name).EntityName;
|
||||||
|
}
|
||||||
|
if (this.AsTables.Any(it => it.Key == name))
|
||||||
|
{
|
||||||
|
name = this.AsTables.First(it => it.Key == name).Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
return string.Format(
|
return string.Format(
|
||||||
this.JoinTemplate,
|
this.JoinTemplate,
|
||||||
joinInfo.JoinType.ToString() + UtilConstants.Space,
|
joinInfo.JoinType.ToString() + UtilConstants.Space,
|
||||||
Builder.GetTranslationTableName(joinInfo.TableName) + UtilConstants.Space,
|
Builder.GetTranslationTableName(name) + UtilConstants.Space,
|
||||||
joinInfo.ShortName + UtilConstants.Space + (TableWithString == SqlWith.Null ? " " : TableWithString),
|
joinInfo.ShortName + UtilConstants.Space + (TableWithString == SqlWith.Null ? " " : TableWithString),
|
||||||
joinInfo.JoinWhere);
|
joinInfo.JoinWhere);
|
||||||
}
|
}
|
||||||
@ -484,7 +497,12 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var result = Builder.GetTranslationTableName(EntityName);
|
var name = EntityName;
|
||||||
|
if (this.AsTables.Any(it=>it.Key==EntityName))
|
||||||
|
{
|
||||||
|
name = this.AsTables.FirstOrDefault(it => it.Key == EntityName).Value;
|
||||||
|
}
|
||||||
|
var result = Builder.GetTranslationTableName(name);
|
||||||
result += UtilConstants.Space;
|
result += UtilConstants.Space;
|
||||||
if (result.Contains("MergeTable") && result.Trim().EndsWith(" MergeTable"))
|
if (result.Contains("MergeTable") && result.Trim().EndsWith(" MergeTable"))
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ namespace SqlSugar
|
|||||||
public virtual string GetTranslationTableName(string name)
|
public virtual string GetTranslationTableName(string name)
|
||||||
{
|
{
|
||||||
Check.ArgumentNullException(name, string.Format(ErrorMessage.ObjNotExist, "Table Name"));
|
Check.ArgumentNullException(name, string.Format(ErrorMessage.ObjNotExist, "Table Name"));
|
||||||
if (name.IsContainsIn("(", ")", SqlTranslationLeft)&&name!= "Dictionary`2")
|
if (!name.Contains("<>f__AnonymousType") &&name.IsContainsIn("(", ")", SqlTranslationLeft)&&name!= "Dictionary`2")
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user