mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Synchronization code
This commit is contained in:
parent
59a9725126
commit
803d6356fc
@ -353,6 +353,40 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
private void _ThenMapper<T>(IEnumerable<T> list, Action<T> action)
|
||||
{
|
||||
MapperContext<T> result = new MapperContext<T>();
|
||||
result.context = this.Context;
|
||||
if (result.context.TempItems == null)
|
||||
{
|
||||
result.context.TempItems = new Dictionary<string, object>();
|
||||
}
|
||||
var key = "Queryable_To_Context";
|
||||
result.context.TempItems.Add(key, result);
|
||||
result.list = list.ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
action.Invoke(item);
|
||||
}
|
||||
result.context.TempItems.Remove(key);
|
||||
}
|
||||
private async Task _ThenMapperAsync<T>(IEnumerable<T> list, Func<T, Task> action)
|
||||
{
|
||||
MapperContext<T> result = new MapperContext<T>();
|
||||
result.context = this.Context;
|
||||
if (result.context.TempItems == null)
|
||||
{
|
||||
result.context.TempItems = new Dictionary<string, object>();
|
||||
}
|
||||
var key = "Queryable_To_Context";
|
||||
result.context.TempItems.Add(key, result);
|
||||
result.list = list.ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
await action.Invoke(item);
|
||||
}
|
||||
result.context.TempItems.Remove(key);
|
||||
}
|
||||
internal string GetN()
|
||||
{
|
||||
var N = "N";
|
||||
|
@ -1665,37 +1665,18 @@ namespace SqlSugar
|
||||
}
|
||||
public void ThenMapper<T>(IEnumerable<T> list, Action<T> action)
|
||||
{
|
||||
MapperContext<T> result = new MapperContext<T>();
|
||||
result.context = this.Context;
|
||||
if (result.context.TempItems == null)
|
||||
this.Context.Utilities.PageEach(list, 200, pageList =>
|
||||
{
|
||||
result.context.TempItems = new Dictionary<string, object>();
|
||||
}
|
||||
var key = "Queryable_To_Context";
|
||||
result.context.TempItems.Add(key, result);
|
||||
result.list = list.ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
action.Invoke(item);
|
||||
}
|
||||
result.context.TempItems.Remove(key);
|
||||
_ThenMapper(pageList, action);
|
||||
});
|
||||
}
|
||||
|
||||
public async Task ThenMapperAsync<T>(IEnumerable<T> list, Func<T, Task> action)
|
||||
{
|
||||
MapperContext<T> result = new MapperContext<T>();
|
||||
result.context = this.Context;
|
||||
if (result.context.TempItems == null)
|
||||
await this.Context.Utilities.PageEachAsync(list, 200,async pageList =>
|
||||
{
|
||||
result.context.TempItems = new Dictionary<string, object>();
|
||||
}
|
||||
var key = "Queryable_To_Context";
|
||||
result.context.TempItems.Add(key, result);
|
||||
result.list = list.ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
await action.Invoke(item);
|
||||
}
|
||||
result.context.TempItems.Remove(key);
|
||||
await _ThenMapperAsync(pageList, action);
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user