@@ -12,8 +12,8 @@ version: "2"
1212plugins :
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
1717sql :
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
103103More 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>
0 commit comments