mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update json 2 sql
This commit is contained in:
parent
a35f8b164d
commit
f2191431e2
@ -7,7 +7,7 @@ namespace SqlSugar
|
||||
{
|
||||
public class GroupByModel
|
||||
{
|
||||
public string FieldName { get; set; }
|
||||
public object FieldName { get; set; }
|
||||
public static List<GroupByModel> Create(params GroupByModel[] groupModels)
|
||||
{
|
||||
return groupModels.ToList();
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
namespace SqlSugar
|
||||
{
|
||||
public abstract partial class SqlBuilderProvider : SqlBuilderAccessory, ISqlBuilder
|
||||
@ -10,13 +11,18 @@ namespace SqlSugar
|
||||
public KeyValuePair<string, SugarParameter[]> GroupByModelToSql(List<GroupByModel> models)
|
||||
{
|
||||
StringBuilder sql = new StringBuilder("");
|
||||
SugarParameter[] pars = new SugarParameter[] { };
|
||||
var pars = new List<SugarParameter> { };
|
||||
foreach (var item in models)
|
||||
{
|
||||
if (item is GroupByModel)
|
||||
if (item is GroupByModel && item.FieldName is IFuncModel)
|
||||
{
|
||||
var orderByModel = item as GroupByModel;
|
||||
sql.Append($" {this.GetTranslationColumnName(orderByModel.FieldName.ToSqlFilter())} ,");
|
||||
sql.Append($" {GetSqlPart(item.FieldName, pars)} ,");
|
||||
}
|
||||
else if (item is GroupByModel)
|
||||
{
|
||||
var orderByModel = item as GroupByModel;
|
||||
sql.Append($" {this.GetTranslationColumnName(orderByModel.FieldName.ObjToString().ToSqlFilter())} ,");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -24,7 +30,7 @@ namespace SqlSugar
|
||||
}
|
||||
|
||||
}
|
||||
return new KeyValuePair<string, SugarParameter[]>(sql.ToString().TrimEnd(','), pars);
|
||||
return new KeyValuePair<string, SugarParameter[]>(sql.ToString().TrimEnd(','), pars?.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user