mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
Update Json 2 sql
This commit is contained in:
14
Src/Asp.Net/SqlSugar/Json2Sql/Enums/AsNameFormatType.cs
Normal file
14
Src/Asp.Net/SqlSugar/Json2Sql/Enums/AsNameFormatType.cs
Normal 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
|
||||
}
|
||||
}
|
@@ -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);
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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" />
|
||||
|
Reference in New Issue
Block a user