Skip to content

Latest commit

 

History

History
40 lines (34 loc) · 1.6 KB

README.md

File metadata and controls

40 lines (34 loc) · 1.6 KB

sqlc-gen-cs: a very early beta C# plugin for SQLC

sqlc-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

  1. Clone the repo
  2. In the repo folder run make build
  3. In your C# solution create your SQL files according to SQLC's getting started
  4. 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
  1. Run sqlc generate
  2. 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 files
  • query_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 emit await compatible functions. Defaults to sync functions.