Update Json 2 sql

This commit is contained in:
sunkaixuan
2022-09-27 22:52:16 +08:00
parent ef18a6f1e5
commit be6bf7714c
5 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public enum AsNameFormatType
{
Default = 0,
NoConvert = 1
}
}

View File

@@ -10,6 +10,7 @@ namespace SqlSugar
ISugarQueryable<T> OrderBy(List<OrderByModel> models);
ISugarQueryable<T> GroupBy(List<GroupByModel> models);
ISugarQueryable<T> Select(List<SelectModel> models);
ISugarQueryable<T> Select(List<SelectModel> models,AsNameFormatType type);
ISugarQueryable<T> AS(string tableName, string shortName);
ISugarQueryable<T> AddJoinInfo(string tableName, string shortName, IFuncModel models, JoinType type = JoinType.Left);
ISugarQueryable<T> AddJoinInfo(List<JoinInfoParameter> joinInfoParameters);

View File

@@ -34,6 +34,10 @@ namespace SqlSugar
{
orderByModel.AsName = orderByModel.FiledName.ObjToString();
}
if (orderByModel.AsName.StartsWith(UtilConstants.ReplaceKey))
{
return orderByModel.AsName.Replace(UtilConstants.ReplaceKey, string.Empty);
}
return this.GetTranslationColumnName(orderByModel.AsName);
}

View File

@@ -57,6 +57,22 @@ namespace SqlSugar
this.QueryBuilder.Parameters.AddRange(orderObj.Value);
return this;
}
public ISugarQueryable<T> Select(List<SelectModel> models, AsNameFormatType type)
{
if (type == AsNameFormatType.NoConvert)
{
foreach (var model in models)
{
if (!string.IsNullOrEmpty(model.AsName))
{
model.AsName = (UtilConstants.ReplaceKey + SqlBuilder.SqlTranslationLeft + model.AsName + SqlBuilder.SqlTranslationRight);
model.AsName.ToCheckField();
}
}
}
return Select(models);
}
public ISugarQueryable<T> Having(IFuncModel model)
{
var orderObj = this.SqlBuilder.FuncModelToSql(model);

View File

@@ -135,6 +135,7 @@
<Compile Include="Json2Sql\Entities\JsonQueryResult.cs" />
<Compile Include="Json2Sql\Entities\JsonTableConfig.cs" />
<Compile Include="Json2Sql\Entities\JsonUpdateResult.cs" />
<Compile Include="Json2Sql\Enums\AsNameFormatType.cs" />
<Compile Include="Json2Sql\Enums\Json2SqlType.cs" />
<Compile Include="Json2Sql\Interface\IFuncModel.cs" />
<Compile Include="Json2Sql\Interface\IJsonClient.cs" />