|
1 | 1 | # sqlc-gen-csharp
|
| 2 | +## Usage |
| 3 | +### Configuration |
| 4 | +```yaml |
| 5 | +version: "2" |
| 6 | +plugins: |
| 7 | +- name: csharp |
| 8 | + wasm: |
| 9 | + url: https://github.com/DionyOSS/sqlc-gen-csharp/releases/download/v0.10.0/sqlc-gen-csharp_0.10.0.wasm |
| 10 | + sha256: 613ae249a541ab95c97b362bd1b0b572970edcad5eb2a11806a52d3f95e0f65f |
| 11 | +sql: |
| 12 | + # PostgreSQL Example |
| 13 | + - schema: "examples/authors/postgresql/schema.sql" |
| 14 | + queries: "examples/authors/postgresql/query.sql" |
| 15 | + engine: "postgresql" |
| 16 | + codegen: |
| 17 | + - plugin: csharp |
| 18 | + out: NpgsqlExample |
| 19 | + options: |
| 20 | + driver: Npgsql |
| 21 | + targetFramework: net8.0 |
| 22 | + generateCsproj: true |
| 23 | + filePerQuery: false |
| 24 | + # MySQL Example |
| 25 | + - schema: "examples/authors/mysql/schema.sql" |
| 26 | + queries: "examples/authors/mysql/query.sql" |
| 27 | + engine: "mysql" |
| 28 | + codegen: |
| 29 | + - plugin: csharp |
| 30 | + out: MySqlConnectorExample |
| 31 | + options: |
| 32 | + driver: MySqlConnector |
| 33 | +``` |
| 34 | +### Options Documentation |
| 35 | +| Option | Possible values | Info | |
| 36 | +|------------|---------------------------|-| |
| 37 | +| targetFramework | default: `net8.0`<br/>vaults: `netstandard2.0`, `netstandard2.1`, `net8.0` |Decide on the right target framework for your generated code, meaning the generated code will be compiled to the specified runtime.<br/>For more information and help deciding on the right value, refer to the [Microsoft .NET Standard documentation](https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-1-0). | |
| 38 | +| generateCsproj | default: `true`<br/>values: `false`,`true` | This option is designed to assist you with the integration of SQLC and csharp by generating a `.csproj` file. This converts the generated output to a dynamic link library (DLL), simply a project that you can easily incorporate into your build process. | |
| 39 | +| filePerQuery | default: `false`<br/>values: `false`,`true` | This option allows users control on which `.cs` files to generate, when false it's one file per `.sql` SQLC query file, and when true it's one file per query. | |
| 40 | + |
| 41 | + |
| 42 | +## Supported SQL Engines |
| 43 | +- MySQL via [MySqlConnector](https://www.nuget.org/packages/MySqlConnector) package - [MySqlConnectorDriver](MySqlConnectorDriver/MySqlConnectorDriver.csproj) |
| 44 | +- PostgreSQL via [Npgsql](https://www.nuget.org/packages/Npgsql) package - [NpgsqlDriver](NpgsqlDriver/NpgsqlDriver.csproj) |
| 45 | + |
| 46 | + |
| 47 | +## Examples & Tests |
| 48 | +The below examples in here are automatically tested: |
| 49 | +- [MySqlConnectorExample](MySqlConnectorExample/MySqlConnectorExample.csproj) |
| 50 | +- [NpgsqlExample](NpgsqlExample/NpgsqlExample.csproj) |
2 | 51 |
|
| 52 | + |
| 53 | + |
| 54 | +<br/> |
| 55 | +<br/> |
| 56 | +<br/> |
| 57 | + |
| 58 | + |
| 59 | +# Local plugin development |
3 | 60 | ## Prerequisites
|
4 | 61 | make sure that the following applications are installed and exposed in your path
|
5 | 62 |
|
@@ -28,36 +85,3 @@ Testing the SQLC generated code via a predefined flow:
|
28 | 85 | make test-process-plugin
|
29 | 86 | make test-wasm-plugin
|
30 | 87 | ```
|
31 |
| - |
32 |
| -## Supported SQL Engines |
33 |
| -- MySQL via [MySqlConnector](https://www.nuget.org/packages/MySqlConnector) package - [MySqlConnectorDriver](MySqlConnectorDriver/MySqlConnectorDriver.csproj) |
34 |
| -- PostgreSQL via [Npgsql](https://www.nuget.org/packages/Npgsql) package - [NpgsqlDriver](NpgsqlDriver/NpgsqlDriver.csproj) |
35 |
| - |
36 |
| -## Configuration |
37 |
| -Options available for plugin: |
38 |
| -```yaml |
39 |
| -version: "2" |
40 |
| -plugins: |
41 |
| - - name: csharp |
42 |
| - env: |
43 |
| - - DEBUG |
44 |
| - process: |
45 |
| - cmd: ./dist/SqlcGenCsharpProcess |
46 |
| -sql: |
47 |
| - - schema: "examples/authors/postgresql/schema.sql" |
48 |
| - queries: "examples/authors/postgresql/query.sql" |
49 |
| - engine: "postgresql" |
50 |
| - codegen: |
51 |
| - - plugin: csharp |
52 |
| - out: NpgsqlExample |
53 |
| - options: |
54 |
| - driver: Npgsql |
55 |
| - minimalCsharp: 7.0 |
56 |
| - filePerQuery: true |
57 |
| - generateCsproj: false |
58 |
| -``` |
59 |
| -
|
60 |
| -## Examples & Tests |
61 |
| -The below examples in here are automatically tested: |
62 |
| -- [MySqlConnectorExample](MySqlConnectorExample/MySqlConnectorExample.csproj) |
63 |
| -- [NpgsqlExample](NpgsqlExample/NpgsqlExample.csproj) |
|
0 commit comments