Skip to content

Commit c4a5e29

Browse files
update auto-generated docs (#255)
* update docs * fix readme --------- Co-authored-by: doron050 <8456254+doron050@users.noreply.github.com> Co-authored-by: Doron Eli Rachman <doron050@gmail.com>
1 parent a1a258d commit c4a5e29

3 files changed

Lines changed: 49 additions & 6 deletions

File tree

README.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ version: "2"
1212
plugins:
1313
- name: csharp
1414
wasm:
15-
url: https://github.com/DaredevilOSS/sqlc-gen-csharp/releases/download/v0.17.0/sqlc-gen-csharp.wasm
16-
sha256: 39df119c6f5bd5a82f30e48f296a0e0827668fb7659e87ba5da53c0943a10986
15+
url: https://github.com/DaredevilOSS/sqlc-gen-csharp/releases/download/v0.18.0/sqlc-gen-csharp.wasm
16+
sha256: 5564052d3133c4127c067b7528e2b62e78ccf03cb99c7fc2aade0764b9455125
1717
sql:
1818
# For PostgresSQL
1919
- schema: schema.sql
@@ -101,6 +101,49 @@ More info can be found in [here](https://docs.sqlc.dev/en/stable/reference/query
101101
| sqlc.embed | ✅ | ✅ | ✅ |
102102

103103
More info can be found in [here](https://docs.sqlc.dev/en/stable/reference/macros.html#macros).
104+
105+
### Transactions
106+
Transactions are supported by the plugin.
107+
<br/>
108+
109+
#### Example using a transaction
110+
```C#
111+
public async Task ExampleTransaction(IDbConnection connection)
112+
{
113+
// Begin a transaction
114+
using (var transaction = connection.BeginTransaction())
115+
{
116+
try
117+
{
118+
// Create a new Queries object with the transaction instead of the connection
119+
var queries = QuerySql.WithTransaction(transaction);
120+
121+
// Example: Insert a new author
122+
var newAuthor = await queries.CreateAuthor(new CreateAuthorParams { Name = "Jane Doe", Bio = "Another author" });
123+
124+
// Example: Get the author by ID within the same transaction
125+
var author = await queries.GetAuthor(newAuthor.AuthorID);
126+
127+
// Example: Update the author's bio
128+
await queries.UpdateAuthorBio(new UpdateAuthorBioParams { AuthorID = author.AuthorID, Bio = "Updated bio for Jane Doe" });
129+
130+
// Commit the transaction if all operations are successful
131+
transaction.Commit();
132+
Console.WriteLine("Transaction committed successfully.");
133+
}
134+
catch (Exception ex)
135+
{
136+
// Rollback the transaction if any error occurs
137+
transaction.Rollback();
138+
Console.WriteLine($"Transaction rolled back due to error: {ex.Message}");
139+
throw;
140+
}
141+
}
142+
}
143+
```
144+
145+
More info can be found in [here](https://docs.sqlc.dev/en/stable/howto/transactions.html).
146+
104147
# PostgresSQL
105148
<details>
106149
<summary>:execlastid - Implementation</summary>

docs/02_Quickstart.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ version: "2"
44
plugins:
55
- name: csharp
66
wasm:
7-
url: https://github.com/DaredevilOSS/sqlc-gen-csharp/releases/download/v0.17.0/sqlc-gen-csharp.wasm
8-
sha256: 39df119c6f5bd5a82f30e48f296a0e0827668fb7659e87ba5da53c0943a10986
7+
url: https://github.com/DaredevilOSS/sqlc-gen-csharp/releases/download/v0.18.0/sqlc-gen-csharp.wasm
8+
sha256: 5564052d3133c4127c067b7528e2b62e78ccf03cb99c7fc2aade0764b9455125
99
sql:
1010
# For PostgresSQL
1111
- schema: schema.sql

docs/03_Usage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ More info can be found in [here](https://docs.sqlc.dev/en/stable/reference/query
6363

6464
More info can be found in [here](https://docs.sqlc.dev/en/stable/reference/macros.html#macros).
6565

66-
6766
### Transactions
6867
Transactions are supported by the plugin.
6968
<br/>
@@ -104,4 +103,5 @@ public async Task ExampleTransaction(IDbConnection connection)
104103
}
105104
```
106105

107-
More info can be found in [here](https://docs.sqlc.dev/en/stable/howto/transactions.html).
106+
More info can be found in [here](https://docs.sqlc.dev/en/stable/howto/transactions.html).
107+

0 commit comments

Comments
 (0)