mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 05:13:27 +08:00
update where(tree)
This commit is contained in:
parent
775fecef25
commit
2be033c9af
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@ -653,7 +654,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region
|
#region Page Each
|
||||||
public void PageEach<T>(IEnumerable<T> pageItems,int pageSize, Action<List<T>> action)
|
public void PageEach<T>(IEnumerable<T> pageItems,int pageSize, Action<List<T>> action)
|
||||||
{
|
{
|
||||||
if (pageItems != null&& pageItems.Any())
|
if (pageItems != null&& pageItems.Any())
|
||||||
@ -694,6 +695,55 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public List<IConditionalModel> JsonToConditionalModels(string json)
|
||||||
|
{
|
||||||
|
List<IConditionalModel> conditionalModels = new List<IConditionalModel>();
|
||||||
|
var jarray = this.Context.Utilities.DeserializeObject<JArray>(json);
|
||||||
|
foreach (var item in jarray)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (item.Count() > 0)
|
||||||
|
{
|
||||||
|
IConditionalModel model = new ConditionalTree()
|
||||||
|
{
|
||||||
|
ConditionalList = GetConditionalList(item)
|
||||||
|
};
|
||||||
|
conditionalModels.Add(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return conditionalModels;
|
||||||
|
}
|
||||||
|
private static List<KeyValuePair<WhereType, IConditionalModel>> GetConditionalList(JToken item)
|
||||||
|
{
|
||||||
|
List<KeyValuePair<WhereType, IConditionalModel>> result = new List<KeyValuePair<WhereType, IConditionalModel>>();
|
||||||
|
var values = item.Values().First();
|
||||||
|
foreach (var jToken in values)
|
||||||
|
{
|
||||||
|
WhereType type = (WhereType)Convert.ToInt32(jToken["Key"]);
|
||||||
|
IConditionalModel conditionalModel = null;
|
||||||
|
var value = jToken["Value"];
|
||||||
|
if (value.ToString().Contains("ConditionalList"))
|
||||||
|
{
|
||||||
|
conditionalModel = new ConditionalTree()
|
||||||
|
{
|
||||||
|
ConditionalList = GetConditionalList(value)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
conditionalModel = new ConditionalModel()
|
||||||
|
{
|
||||||
|
ConditionalType = (ConditionalType)Convert.ToInt32(value["ConditionalType"]),
|
||||||
|
FieldName = value["FieldName"] + "",
|
||||||
|
FieldValue = value["FieldValue"] + ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
result.Add(new KeyValuePair<WhereType, IConditionalModel>(type, conditionalModel));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,5 +37,6 @@ namespace SqlSugar
|
|||||||
void PageEach<T>(IEnumerable<T> pageItems, int pageSize, Action<List<T>> action);
|
void PageEach<T>(IEnumerable<T> pageItems, int pageSize, Action<List<T>> action);
|
||||||
Task PageEachAsync<T>(IEnumerable<T> pageItems, int pageSize, Func<List<T>, Task> action);
|
Task PageEachAsync<T>(IEnumerable<T> pageItems, int pageSize, Func<List<T>, Task> action);
|
||||||
Task PageEachAsync<T, ResultType>(IEnumerable<T> pageItems, int pageSize, Func<List<T>, Task<ResultType>> action);
|
Task PageEachAsync<T, ResultType>(IEnumerable<T> pageItems, int pageSize, Func<List<T>, Task<ResultType>> action);
|
||||||
|
List<IConditionalModel> JsonToConditionalModels(string json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user