Re:Making life easier for newcomers to the .NET ecosystem
by bayesian_horse on Monday November 15, 2021 @07:03AM
(#29226404)
I find myself writing at least 5-10 times as much code compared to Python/Django. With the Django ORM once you design your models you already have at least 80% of the logic for a CRUD REST API, form validation, CRUD admin interface (if you want that), and you can easily integrate all sorts of third party features for almost no effort. Migrations are a bit saner because of the App separation, data migrations are a possible.
[ Parent
| on HN ]
Re:Making life easier for newcomers to the .NET ecosystem
by atraac on Monday November 15, 2021 @08:36AM
(#29227155)
You can achieve nearly the same thing by creating your Entities, generating migration from them with a single command, migrating your db with another one(or from code on startup) and returning them directly from Controller's method using DB Context. It's honestly not that much more work. It's far from a recommended approach though... Granted, Django Admin is pretty nice and although there are few nugets that try to achieve that I never found them as easy as in Django.
Re:Making life easier for newcomers to the .NET ecosystem
by bayesian_horse on Tuesday November 16, 2021 @01:49AM
(#29237652)
At least in the codebase I work on, I need to create an IRequest/IRequestHandler/Validator class triplet for every single endpoint, each in its own files, including all the lines with single braces and using statements for all the magic extension methods and dependency injection constructors. And often I need to add new ViewModels because the mapping doesn't work correctly.
DRF is much more convenient.
Re:Making life easier for newcomers to the .NET ecosystem
by NicoJuicy on Wednesday November 17, 2021 @01:20PM
(#29256753)
That's not EF. That's typical cqrs, lol.
Here's a scaffolder as an example if you want to automate things like that: https://github.com/ArmandJ77/CQRSAndMediator-Scaffolding
Re:Making life easier for newcomers to the .NET ecosystem
by atraac on Wednesday November 17, 2021 @06:25AM
(#29251581)
Well this is because you decided yourself to go that route. Amount of work would be the same in Django if you decided on this particular architecture there.
It doesn't change the fact that if you want to do a simple CRUD you can do it equally easy in almost every popular web framework these days, just yolo that shit into your Controller and be done with it. What you're doing is way more maintainable though, especially if you work with an actual team.
Re:Making life easier for newcomers to the .NET ecosystem
by NicoJuicy on Monday November 15, 2021 @09:54AM
(#29228082)
I don't think you know it very well.
You need to add the correct attributes to your class for form validation ( eg. Required / StringLength )
Then scaffold a MVC controller or an api controller ( It will add the class to your DbContext)
Then add-migration / update-database for your migration.
And it's done
Re:Making life easier for newcomers to the .NET ecosystem
by bayesian_horse on Tuesday November 16, 2021 @01:43AM
(#29237612)
Which leads us to the topic of documentation and on-boarding. And it's still a ton of more code to write, read and maintain.