Skip to content

Commit

Permalink
[doc] Fix dapper query wrong description #552
Browse files Browse the repository at this point in the history
  • Loading branch information
shps951023 committed Dec 27, 2023
1 parent e1b7951 commit bd1f7d5
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,32 @@ using (var connection = GetConnection(connectionString))
}
```

#### 5. Dapper Query

Thanks @shaofing #552 , please use `CommandDefinition + CommandFlags.NoCache`

```csharp
using (var connection = GetConnection(connectionString))
{
var rows = connection.Query(
new CommandDefinition(
@"select 'MiniExcel' as Column1,1 as Column2 union all select 'Github',2"
, CommandFlags.NoCache)
)
MiniExcel.SaveAs(path, rows);
}
```

Below code will load all data into memory

```csharp
using (var connection = GetConnection(connectionString))
{
var rows = connection.Query(@"select 'MiniExcel' as Column1,1 as Column2 union all select 'Github',2");
MiniExcel.SaveAs(path, rows);
}
```


#### 6. SaveAs to MemoryStream [[Try it]](https://dotnetfiddle.net/JOen0e)

Expand Down
16 changes: 15 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,21 @@ MiniExcel.SaveAs(path, table);

#### 5. Dapper Query

- `不推荐使用`,会将数据全载入内存,建议使用`ExecuteReader`
感谢 @shaofing #552 更正,低内存请使用 `CommandDefinition + CommandFlags.NoCache`,如下

```csharp
using (var connection = GetConnection(connectionString))
{
var rows = connection.Query(
new CommandDefinition(
@"select 'MiniExcel' as Column1,1 as Column2 union all select 'Github',2"
, CommandFlags.NoCache)
)
MiniExcel.SaveAs(path, rows);
}
```

以下写法会将数据全载入内存

```csharp
using (var connection = GetConnection(connectionString))
Expand Down
16 changes: 15 additions & 1 deletion README.zh-Hant.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,21 @@ MiniExcel.SaveAs(path, table);

#### 5. Dapper Query

- `不推薦使用`,會將數據全載入Memory,建議使用`ExecuteReader`
感謝 @shaofing #552 更正,低內存請使用 `CommandDefinition + CommandFlags.NoCache`,如下

```csharp
using (var connection = GetConnection(connectionString))
{
var rows = connection.Query(
new CommandDefinition(
@"select 'MiniExcel' as Column1,1 as Column2 union all select 'Github',2"
, CommandFlags.NoCache)
)
MiniExcel.SaveAs(path, rows);
}
```

以下寫法會將數據全載入內存

```csharp
using (var connection = GetConnection(connectionString))
Expand Down

0 comments on commit bd1f7d5

Please sign in to comment.