-
Notifications
You must be signed in to change notification settings - Fork 851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add C# support #373
Comments
I would. The main issue that I don't know what good C# support would look like. Kotlin support was added by a contributor, so I see no reason by C# couldn't be added the same way. The first step would be to gather some more information. What does your current setup look like? What code are you writing by hand? What libraries are you using? |
Currently the following libraries are used when I work with postgres and c#:
My setup is to hand write the C# classes and the sql, then dapper (micro orm) providing the mapping from sql to my C# POCO class with the help of reflection. The thing is that I need to manually keep track that my queries and the c# class needs to match - this can be a bit error prone at times. Let me try and come up with an example of how the auto generated code could look like in the next couple of days. |
Hey, Just recently found that library and it looks really cool, especially when its use is considered for projects already managing DB entities with rather low-level ORMs like aforementioned Dapper. @kyleconroy - is C# support is still something you'd still actively consider? There're in fact three main approaches when building an app in C# with DB communication in mind:
Dapper is a DB-agnostic ORM meaning it supports many (if not all) .NET ADO providers being an interesting safe choice. Pure ADO.NET may be closer to your original approach for I'd say the best option would be to get started with Dapper (as it abstracts many lower-level concepts from ADO.NET) and give it a try as the simplest option. |
Personally I think pure ADO.NET with Npgsql is the right way to go. Dapper, IMO, adds an unnecessary layer of reflection-based object field mapping. The point of sqlc is to generate simple, performant, type-safe code to access queries and query results. It doesn't really matter if that code ends up being verbose compared to what you can get with Dapper. I also think there's a strong argument to be made for avoiding another dependency. |
C# support would also mean the need for supporting SQL Server, since that's what the majority of C# projects are running. |
Hi there. The easy way to get C# support is this magic library. https://github.com/jonwagner/Insight.Database I'm trialing it and it's super-easy to set up C# DTOs and interfaces and run existing stored procedures or inline SQL. It's like Dapper, but on steriods. No EF Context 💩. No need to fill in the gaps for ADO.NET. Just pure bliss as advertised (at least, so far that's been my experience). |
For anyone interested in SQLC for C# TLDRversion: "2"
plugins:
- name: csharp
wasm:
url: https://github.com/DionyOSS/sqlc-gen-csharp/releases/download/v0.10.0/sqlc-gen-csharp_0.10.0.wasm
sha256: 613ae249a541ab95c97b362bd1b0b572970edcad5eb2a11806a52d3f95e0f65f
sql:
# PostgreSQL Example
- schema: "examples/authors/postgresql/schema.sql"
queries: "examples/authors/postgresql/query.sql"
engine: "postgresql"
codegen:
- plugin: csharp
out: NpgsqlExample
options:
driver: Npgsql
targetFramework: net8.0
generateCsproj: true
filePerQuery: false
# MySQL Example
- schema: "examples/authors/mysql/schema.sql"
queries: "examples/authors/mysql/query.sql"
engine: "mysql"
codegen:
- plugin: csharp
out: MySqlConnectorExample
options:
driver: MySqlConnector For further information refer to https://github.com/DaredevilOSS/sqlc-gen-csharp |
@kyleconroy can be closed then:) |
Hi, @kyleconroy, just a reminder, can be closed :) |
I was waiting for everything to be stable. Sounds like that just happened this month. Closing! |
First of all, I'm a huge fan of sqlc and I use it every single personal go project where I need database support. Good work 🙏
I noticed that you have started adding support for other languages incl. typescript and kotlin. In my day to day work I write a lot of code in C# which use postgres database.
Would you consider adding support for C# based apps?
I might be able to help but I'm still learning Go so I might need some support in how to get started if you want help with this
The text was updated successfully, but these errors were encountered: