r/StackoverReddit • u/No-Hippo1667 • Jul 16 '24
C# an idea about common CRUD API
I find I was doing repetitive work in the past years,
- change the model add/change fields,
- update DB,
- change API (service/controller)
- change Page
So I think maybe I can write common CRUD API, it will serve CRUD for every entities. my model definition is not in code, but in configuration.
I invite you to check out my repo, https://github.com/fluent-cms/fluent-cms , maybe some ideas can inspire you
My initial thought is my API should be slower than write API manually , due to I have to use another lib SQLKate to build the SQL, and using Dictionary<string, any> to read record and serialize json should be slower than a predefined c# class.
Luckily thanks for SqlKate And Dapper, the API are a little faster than EF, (the SQL generated are very similar)
View all comments
Show parent comment
1
u/Embarrassed-Flow3138 Jul 17 '24
You know... not a bad approach actually.
It seems more intuitive and easier to maintain than a plugin approach. It might be useful to include a on-Exception callback in that case too.
It hurts my petty little soul a bit to have the lines between managing it from the frontend and then doing some of the work on the C# side still. But don't let me detract you from exploring your ideas, I think you've done exceptional work so far!