SQLC
sqlc-gen-cs: a very early beta C# plugin forsqlc-gen-cs is a beta plugin for adding C# support via ADO .Net to SQLC
this plugin currently only supports Postgresql and cannot handle Enums! We're looking to expand this support very soon!
Getting Started
- Clone the repo
- In the repo folder run
make build
- In your C# solution create your SQL files according to SQLC's getting started
- Change you sqlc.yaml to the following, editing the configuration accordingly
version: "2"
sql:
- engine: "postgresql"
queries: "queries.sql"
schema: "schema.sql"
codegen:
- out: models
plugin: sqlc-gen-cs
options:
namespace: hyperbeam.models
query_param_limit: 1
emit_async: true
plugins:
- name: sqlc-gen-cs
process:
cmd: ./path/to/sqlc-gen-cs
- Run sqlc generate
- Enjoy your new CS files (Maybe run
dotnet format
on them too)
Configuration
Currently supported plugin configuration options are:
- Most language agnostic config options from Sqlc as seen here barring engine. If you find any unsupported options open up an issue!
namespace
- The namespace for the generated filesquery_param_limit
- The amount of parameters to inline in the function declaration before creating a new class. -1 is no limit, 0 is invalid.emit_async
- whether or not to emitawait
compatible functions. Defaults to sync functions.