mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-16 05:10:55 +08:00
Updated Return Data (markdown)
@@ -149,13 +149,19 @@ Dto query only maps default fields (common attributes). For mapping objects, ple
|
||||
Execute queries and return data in blocks, which can reduce memory overhead. For example, if 100,000 pieces of data are read, 100 pieces of data are returned for processing each time.
|
||||
|
||||
```csharp
|
||||
var testlist1 = fsql.Select<Song>().OrderBy(a => a.Id).ToList();
|
||||
var testlist2 = new List<Song>();
|
||||
fsql.Select<Song>().OrderBy(a => a.Id).ToChunk(100, done => {
|
||||
testlist2.AddRange(done.Object);
|
||||
//done.IsBreak = true; v1.7.0 stop reading
|
||||
fsql.Select<Song>().OrderBy(a => a.Id).ToChunk(100, done =>
|
||||
{
|
||||
List<Song> list = done.Object;
|
||||
//done.IsBreak = true; v1.7.0 停止读取
|
||||
});
|
||||
//Here is a demonstration that the final data returned by testlist1 and testlist2 are the same.
|
||||
|
||||
//VNext
|
||||
var asyncEnum = fsql.Select<Song>().OrderBy(a => a.Id).ToChunkAsyncEnumerable(100);
|
||||
await foreach (var items in asyncEnum)
|
||||
{
|
||||
foreach (var item in items)
|
||||
Console.WriteLine(item.Nickname);
|
||||
}
|
||||
```
|
||||
|
||||
## ToSql
|
||||
|
||||
Reference in New Issue
Block a user