What's is good ASP.NET web API project structure
Can you recommend good project structure for small or medium web api project? Maybe you have a link to an example. I read about DDD or "Clean Architecture", but it looks over complicated. I was thinking about modular, but should I split modules is different projects or keep them in one separate?
24 Replies
$vsa
tl;dr organize each feature into its own folder and don't worry about layers or where to put things
one more question, do I really need to create a repository class between service and storage (sql, mongodb or redis) if I'm using Entity Framework or other similar library?
no, in fact the opposite
EF already implements unit of work (DbContext) and generic repositories (DbSet) so there's no point in making an additional abstraction over it
great, thank you
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
it's just that mongodb is most popular database in tutorials (not c# of course) because it has free tier and I used it sometimes
lots of databases are free
sqlite, postgres, the dev version of sql server, mysql (yuck)
mongodb is significantly different than those because it's not a relational database
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
yes, but I mean free tier for hosted database, you can open MongoDb atlas, create instance and use it with your API hosted somewhere for free. I used host that allows to deploy only web API without database which was also free
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
sqlite doesn't need to be hosted at all
that does not make sense for me too. I they want their database to be used in C# why they wouldn't integrate it with AspNetCore
the point is mongo is a very different kind of DB than most applications should be using
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
that sucks if they don't so much about c#, I got many questions about
GetDatabase
too, like should I store it or get it on every request, is it always new instance and where store name for database. The worst thing was aggregation which I wanted to use to combine data from several tables and filter them and it was way too complicated because they suggest you to use json like syntax and I end up using two different queries.
some hosts don't allow you to create any files besides deployed files 😦get a plain old VPS then you can do whatever you want on it
that's can be a solution
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
studying new API when you always use
LINQ
definitely is a painUnknown User•8mo ago
Message Not Public
Sign In & Join Server To View
🤣
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View