Code optimization

This commit is contained in:
skx 2021-01-17 23:56:54 +08:00
parent 1e6f05c1c6
commit a0fb511e95
3 changed files with 13 additions and 15 deletions

View File

@ -93,11 +93,11 @@ namespace OrmTest
))
.Select((o, i, c) => new { o,i}).ToList();
List<Dictionary<string, object>> ListDic = db.Queryable<Order, OrderItem, Custom>((o, i, c) => new JoinQueryInfos(
JoinType.Left, o.Id == i.OrderId,
JoinType.Left, o.CustomId == c.Id
))
.Select<ExpandoObject>().ToList().Select(it => it.ToDictionary(x => x.Key, x => x.Value)).ToList();
var mergeList= db.Queryable<Order>()
.Select(it => new { id = it.Id })
.MergeTable().Select<Order>().ToList();
Console.WriteLine("#### ReturnType End ####");
}

View File

@ -1373,15 +1373,7 @@ namespace SqlSugar
}
protected ISugarQueryable<T> _As(string tableName, string entityName)
{
IsAs = true;
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;
this.QueryBuilder.AsTables.Add(entityName, tableName);
return this;
}
protected void _Filter(string FilterName, bool isDisabledGobalFilter)

View File

@ -114,6 +114,7 @@ namespace SqlSugar
#endregion
#region Sql Template
public Dictionary<string, string> AsTables=new Dictionary<string, string>();
public virtual string SqlTemplate
{
get
@ -484,7 +485,12 @@ namespace SqlSugar
{
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;
if (result.Contains("MergeTable") && result.Trim().EndsWith(" MergeTable"))
{