C
C#•8mo ago
Alex

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
Jimmacle
Jimmacle•8mo ago
$vsa
Jimmacle
Jimmacle•8mo ago
tl;dr organize each feature into its own folder and don't worry about layers or where to put things
Alex
AlexOP•8mo ago
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?
Jimmacle
Jimmacle•8mo ago
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
Alex
AlexOP•8mo ago
great, thank you
Unknown User
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Alex
AlexOP•8mo ago
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
Jimmacle
Jimmacle•8mo ago
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
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Alex
AlexOP•8mo ago
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
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Jimmacle
Jimmacle•8mo ago
sqlite doesn't need to be hosted at all
Alex
AlexOP•8mo ago
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
Jimmacle
Jimmacle•8mo ago
the point is mongo is a very different kind of DB than most applications should be using
Unknown User
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Alex
AlexOP•8mo ago
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 😦
Jimmacle
Jimmacle•8mo ago
get a plain old VPS then you can do whatever you want on it
Alex
AlexOP•8mo ago
that's can be a solution
Unknown User
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Alex
AlexOP•8mo ago
studying new API when you always use LINQ definitely is a pain
Unknown User
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Alex
AlexOP•8mo ago
🤣
Unknown User
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server