mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-01-23 13:21:59 +08:00
Update json 2 sql
This commit is contained in:
@@ -7,7 +7,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public class GroupByModel
|
public class GroupByModel
|
||||||
{
|
{
|
||||||
public string FieldName { get; set; }
|
public object FieldName { get; set; }
|
||||||
public static List<GroupByModel> Create(params GroupByModel[] groupModels)
|
public static List<GroupByModel> Create(params GroupByModel[] groupModels)
|
||||||
{
|
{
|
||||||
return groupModels.ToList();
|
return groupModels.ToList();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public abstract partial class SqlBuilderProvider : SqlBuilderAccessory, ISqlBuilder
|
public abstract partial class SqlBuilderProvider : SqlBuilderAccessory, ISqlBuilder
|
||||||
@@ -10,13 +11,18 @@ namespace SqlSugar
|
|||||||
public KeyValuePair<string, SugarParameter[]> GroupByModelToSql(List<GroupByModel> models)
|
public KeyValuePair<string, SugarParameter[]> GroupByModelToSql(List<GroupByModel> models)
|
||||||
{
|
{
|
||||||
StringBuilder sql = new StringBuilder("");
|
StringBuilder sql = new StringBuilder("");
|
||||||
SugarParameter[] pars = new SugarParameter[] { };
|
var pars = new List<SugarParameter> { };
|
||||||
foreach (var item in models)
|
foreach (var item in models)
|
||||||
{
|
{
|
||||||
if (item is GroupByModel)
|
if (item is GroupByModel && item.FieldName is IFuncModel)
|
||||||
{
|
{
|
||||||
var orderByModel = item as GroupByModel;
|
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
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user