Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ToChunk增加异步Api #1952

Open
ROMYIM opened this issue Dec 20, 2024 · 0 comments
Open

ToChunk增加异步Api #1952

ROMYIM opened this issue Dec 20, 2024 · 0 comments

Comments

@ROMYIM
Copy link

ROMYIM commented Dec 20, 2024

Feature 特性

Task ToChunkAsync<TReturn>(Expression<Func<T1, TReturn>> select, int size, Func<FetchCallbackArgs<List<TReturn>>, CancellationToken, ValueTask> done, Cancellationtoken token = default);

简要描述原因

一般大数据操作后续都会涉及注入文件导出,请求调用等IO操作。及其需要异步API版本的支持

使用场景

       var streamWriter = new StreamWriter(File.OpenWrite(string.Empty));

        dto.Editable = !await freeSql.Select<SysFlowActivity>().WithLock()
            .Where(activity => activity.ObjId == appCaseList.ApplyId)
            .Where(activity => activity.FlowType == FlowType.ApplyOpenCase)
            .Where(activity => activity.Status != 0)
            .ToChunkAsync(100, async (args, token) =>
            {
                var data = args.Object;
                foreach (var d in data)
                {
                    await streamWriter.WriteLineAsync(d.Id);
                }
            })
            .AnyAsync(cancellationToken);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant