C# Type Generation #119
Replies: 1 comment 2 replies
-
Not that I know of off the top of my head. Historically this has been an area targeted by ORMs, which usually sit on the middle tier in a secure environment. You would just point your tooling at the ODBC connection string and hit the database directly. There are a lot of C# (and FWIW Java) tools and frameworks that are expecting to sit in the middle as a REST->SQL service. I just did a quick search for traditional C# ORMs and found a ton of stuff (I'm more of a Java dev by background). Off the cuff there's NHibernate, Entity Framework, Dapper, and a search turned up a ton of others... FWIW what I did with my Unity project was to create the backend using pl/SQL stored procedures in the public schema, and then have my data in an app schema. I wrote C# test cases to hit those auto-generated REST services from the public schema to validate both the functionality and the async/await stuff. I used a standard RDMBS modeling tool to generate and manage the schema, including backups. I actually found this much easier than trying to use a traditional ORM. I did have to write C# types for the data coming coming back from the RPCs but TBH it really wasn't that much work. |
Beta Was this translation helpful? Give feedback.
-
Does anyone know of any way to automatically generate C# types from a Supabase database, in the same way you can generate Typescript types by using the command
npx supabase gen types typescript
?For context, I am hoping I can find a way to define schemas/types in one place (such as a .prisma file), perform a database migration, perform a codegen step that is equivalent to the non-existent command
npx supabase gen types csharp
, and end up with types that I can use with supabase-csharp's strongly-typed LINQ-like interface (i.e. those generated types are derived from BaseModel, their properties all have the correct attributes, etc.).It appears there is no ready-made way to do this, so I am considering trying to implement a way myself (probably by generating the typescript types first and then converting them to C#), but I wanted to find out if any similar effort might already be underway, or already exists and I somehow missed it.
Thank in advance for any insights you can provide!
Beta Was this translation helpful? Give feedback.
All reactions