Milan, I work at a company that heavily relies on Dapper, although in a somewhat anemic domain. While attempting to implement a Rich Domain using DDD's tactical patterns (such as value objects, entities, aggregates, etc.) in some projects, I encountered significant challenges when it came to mapping my aggregates with Dapper. Consequently, I ended up utilizing reflection and protected constructors with signatures that match the projection. It would be incredibly insightful if you could create a video discussing how to effectively leverage Dapper in such scenarios. Your freely shared content on RUclips is greatly appreciated. P.S. I'm thoroughly enjoying your Pragmatic Clean Architecture course!
I actually made a video about this a while ago, talking about the Snapshot/Memento pattern 👇 ruclips.net/video/HhZ4DtON404/видео.html P.S. If you get value from the course, it would mean the world to me if you leave a testimonial. ❤️
Super simple, clean and efficient..... I haven't messed with Minimal APIs that much(I guess once back about 1+ yr), Thank you for making this. However, I would rather stick with EFCore+Automapper(I hope you will do a video about it too) to avoid raw SQL queries/stuff.
@@MilanJovanovicTech interesting.😊 but curious to know why?? btw I'm trying out Dapper wih different DB Providers(I mostly use Mysql/Postgres), I maybe move an old project that uses direct sql queries with cmd to Dapper(while migrating it to dotnet 7)
Great introduction please take it to next level , and show how to get the same featurea in ef core like change tracker , logging , exception handling and more❤
Hi Milan, can you please make a video about "vertical slice architecture" maybe with comparison to clean code archecture and which you would prefer and when?
Hey, thanks for the video. Could you please give more details about not to register a SqlConnectionFactory as a singleton service? I dont understand provided example.
The .Addsingleton is used coz the connection to the database is established once my application session(at the start) and the re-used as a connection pool.
I am from Egypt and I have been following the channel for a long time. I would like to thank you for that great explanation, Engineer Milan. I hope that you will give me your social media links to follow all your posts.
Excellent video. I left .Net probably 8 years ago. wanted to learn quickly .net 8 core as we have a requirement in our company to build application in .Net 8 with Blazer, Syncfusion, MVP framework. Is there a video or tutorial on how to quickly upgrade skills. I do not need to be an expert but decent knowledge is fine. Appreciate your help.
Hello, I am creating a project using dapper with onion architecture. Since I was using Dapper, I could not adapt the identity and jwt token packages to the project. Can you help with this?
Thank you for great explanation. I am following all of your videos and they are really great. One question though: what’s the point of using minimal apis if we encapsulate all our endpoints in separate class? Is the same if we use controllers. Why do you create CustomerEndpoints instead of CustomersController? Thank you
@@MilanJovanovicTech fair question :)) in my opinion, minimal api was introduced to reduce responsibilities to API and create micro services. E.g. customers service is containing only endpoints for customers and that’s all. All of the related endpoints i guess would be in program.cs. But anyways, i agree on your choice to organize the code the way you did, i was just wondering if you had more reasons to do so. Thank you for your videos, your progress is remarkable
Hello, I have a question, the order is created, and the orderItem is created at the same time. Is the creation of the orderItem operated in the orderCommandHandler or what? Or modify the inventory, where should I go to operate? looking forward to your reply
It's not insecure at all when used properly with parameterisation (Marc Gravell wrote a blog post in 2017 on the subject if you want to read more on that), however I agree that the use of inline SQL is what really turns me off using Dapper.
can you guide me how to create backend received emails like other website platforms ? is there possible to making this thing or not because i dont even find any tutorials like that like gmail recevied other website emails and news also outlook received same to same that type of thing i want make so do you know any thing like that
@MilanJovanovicTech not a lot of documentation, but I love it. The only problem is that it keeps private, the transaction, so you can't combine it with your own queries without turning to reflection. But I don't see you use transactions, so you may be in the clear :-p
Hi! In your new course, i was reading the curriculum and i have a doubt. In this course, you talk about modular-monolith and integration events? Thanks you a lot for the content!
The course is focused on building a monolith, in a modular way. There is only one module, however. I didn't want to overwhelm the student with complexity.
Really informative videos dear Milan! Thank you for your hard work. Can you please tell me if can we use same api controller to cater different countries by using countrycode in url?
Hi Milan! How do you approach many to many relationships in DDD with ef core? Most examples in the Internet only show one to one and one to many. Some people use owned relationships. But no-one shows how to do that with many to many relationship.
@@MilanJovanovicTech Do you know any good articles about this? You're right in a sense that I may not need such concept in domain models (still don't know how to do that). However, my domain models are also the models I save in the database (I know that ideally they should be different, but honestly I haven't seen any good example on GitHub). Maybe you could make some video where you try to model some tricky relationships, etc.?
is not it better to inejct IConfiguration inside SqlConnectionFactory and get connection string inside rather than pass it as parameter? or it is better in terms of isolation to make it like this?
Maybe I don't want any improvement. I just want to make a simple application. It's okay if many things are on a single page. I might not need new complications. Sometimes improvements serve no purpose other than adding complexity. It's better to keep it simple unless necessary. If needed, we can deal with improvements. Perhaps the person who comes after me will understand this code better if there are no improvements. Everyone doesn't have to know everything. People have other things to do as well.
It's all fun and games until you get enormous tables containing 100+ of columns. Is there a way of deal with them using Dapper without having to write the whole sql?
Want to master Clean Architecture? Go here: bit.ly/3PupkOJ
Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt
Clean and efficient! Thank you Milan.
Any time!
It would be good make a new video improving this API, spliting it in layers (Repository, Services, ...) and implementing unit tests.
Perhaps, but this is enough for a beginner to get started
Please take it to the next level
Milan, I work at a company that heavily relies on Dapper, although in a somewhat anemic domain. While attempting to implement a Rich Domain using DDD's tactical patterns (such as value objects, entities, aggregates, etc.) in some projects, I encountered significant challenges when it came to mapping my aggregates with Dapper. Consequently, I ended up utilizing reflection and protected constructors with signatures that match the projection. It would be incredibly insightful if you could create a video discussing how to effectively leverage Dapper in such scenarios. Your freely shared content on RUclips is greatly appreciated.
P.S. I'm thoroughly enjoying your Pragmatic Clean Architecture course!
I actually made a video about this a while ago, talking about the Snapshot/Memento pattern 👇
ruclips.net/video/HhZ4DtON404/видео.html
P.S. If you get value from the course, it would mean the world to me if you leave a testimonial. ❤️
Didn't know about the option for route groups, thanks for showing us that . Would love to see how you would unit test this.
I'll make a video about it :)
Super simple, clean and efficient.....
I haven't messed with Minimal APIs that much(I guess once back about 1+ yr), Thank you for making this.
However, I would rather stick with EFCore+Automapper(I hope you will do a video about it too) to avoid raw SQL queries/stuff.
I despise Automapper 😁
@@MilanJovanovicTech interesting.😊 but curious to know why??
btw I'm trying out Dapper wih different DB Providers(I mostly use Mysql/Postgres), I maybe move an old project that uses direct sql queries with cmd to Dapper(while migrating it to dotnet 7)
Great introduction please take it to next level , and show how to get the same featurea in ef core like change tracker , logging , exception handling and more❤
Might end up doing it 🤔
Hi Milan, can you please make a video about "vertical slice architecture" maybe with comparison to clean code archecture and which you would prefer and when?
Sure
@@MilanJovanovicTech thank you!
Thaks a lot. Can I creating a Database with Code First in minimal API project ?
Yes
Hey, thanks for the video. Could you please give more details about not to register a SqlConnectionFactory as a singleton service? I dont understand provided example.
The .Addsingleton is used coz the connection to the database is established once my application session(at the start) and the re-used as a connection pool.
It can be a singleton also - just not if you want to store and reuse the current connection inside.
What would be the difference between creating a controller vs using minimal api if we are moving the code from program.cs?
Will you have 200 endpoints in Program.cs?
Minimal APIs are more performant
Superb. Thank you.
You're welcome!
What do you think of relationships using dapper and having nested objects in C# based on the relationships?
Becomes difficult to manage, but it's definitely doable
I am from Egypt and I have been following the channel for a long time. I would like to thank you for that great explanation, Engineer Milan. I hope that you will give me your social media links to follow all your posts.
www.milanjovanovic.tech/#socials
How can we merge Clean Arquitecture and DDD with Dapper instead of EF Core?
Put all your SQL logic in repositories that get called by either Application layer services or CQRS commands and queries.
It'a definitely harder, since there is no UoW. One option is the Snapshot pattern.
thx i do a little research on that@@MilanJovanovicTech
Excellent video. I left .Net probably 8 years ago. wanted to learn quickly .net 8 core as we have a requirement in our company to build application in .Net 8 with Blazer, Syncfusion, MVP framework. Is there a video or tutorial on how to quickly upgrade skills. I do not need to be an expert but decent knowledge is fine.
Appreciate your help.
I doubt such a video exists
Hi brother, I am also in the same situation like you, have you found any good resources?
Are there no vulnerabilities, like SQL Injection?
Not if you parameteriz queries
Did you use Dapper here both to connect to the database and to execute APIs?
I think the answer is yes (from my understanding of your question)
Please do more videos like this where we see you write code from the beginning
Will do!
what's the theme you are using in visual studio? i like it
ReSharper + syntax highlighting
Hello, I am creating a project using dapper with onion architecture. Since I was using Dapper, I could not adapt the identity and jwt token packages to the project. Can you help with this?
Nope
Thank you for great explanation. I am following all of your videos and they are really great. One question though: what’s the point of using minimal apis if we encapsulate all our endpoints in separate class? Is the same if we use controllers. Why do you create CustomerEndpoints instead of CustomersController? Thank you
Where else would they live? 😁
@@MilanJovanovicTech fair question :)) in my opinion, minimal api was introduced to reduce responsibilities to API and create micro services. E.g. customers service is containing only endpoints for customers and that’s all. All of the related endpoints i guess would be in program.cs. But anyways, i agree on your choice to organize the code the way you did, i was just wondering if you had more reasons to do so. Thank you for your videos, your progress is remarkable
Hello, I have a question, the order is created, and the orderItem is created at the same time. Is the creation of the orderItem operated in the orderCommandHandler or what? Or modify the inventory, where should I go to operate? looking forward to your reply
I'd say both are updated in the same handler
thank you🤝@@MilanJovanovicTech
Really good explanation, however I feel like this Dapper thing wanting literal TSQL strings is really insecure and hellish to maintain in the future
You can easily use Stored Procedures with Dapper too if you prefer to not have TSQL littered about in your code.
It's not insecure at all when used properly with parameterisation (Marc Gravell wrote a blog post in 2017 on the subject if you want to read more on that), however I agree that the use of inline SQL is what really turns me off using Dapper.
Not if you usr parameters
Why did you pick up dapper now instead EF? Are you having issues with speed?
yes, thats the reason Dapper is being preffered, the performance. EF is too slow but more complex
@@azad2096 In past I knew EF was bad in performance but the new version I think are fine.
No, I want to talk about different options
can you guide me how to create backend received emails like other website platforms ? is there possible to making this thing or not because i dont even find any tutorials like that like gmail recevied other website emails and news also outlook received same to same that type of thing i want make so do you know any thing like that
Nope
You should also do a video using dapper rainbow
Interesting, will explore some more 🤔
@MilanJovanovicTech not a lot of documentation, but I love it. The only problem is that it keeps private, the transaction, so you can't combine it with your own queries without turning to reflection. But I don't see you use transactions, so you may be in the clear :-p
which theme are you using?
Dark + R#
Hi! In your new course, i was reading the curriculum and i have a doubt. In this course, you talk about modular-monolith and integration events? Thanks you a lot for the content!
The course is focused on building a monolith, in a modular way. There is only one module, however. I didn't want to overwhelm the student with complexity.
Really informative videos dear Milan! Thank you for your hard work.
Can you please tell me if can we use same api controller to cater different countries by using countrycode in url?
As a query parameter? Seems doable
@@MilanJovanovicTech Thanks for your reply 🙂👍 What should be the best practice for such scenario.🤔 I dont want long if else statements
but what is the advantage of dapper over entity framework?
Simpler to be productive. You just need to write SQL and map to an object. And it's typically more performant since it's doing less work.
Hi Milan! How do you approach many to many relationships in DDD with ef core? Most examples in the Internet only show one to one and one to many. Some people use owned relationships. But no-one shows how to do that with many to many relationship.
Do you even need such a concept (other than in the DB) in your domain model? Because most problems can be solved without it, and it's simpler
@@MilanJovanovicTech Do you know any good articles about this? You're right in a sense that I may not need such concept in domain models (still don't know how to do that). However, my domain models are also the models I save in the database (I know that ideally they should be different, but honestly I haven't seen any good example on GitHub). Maybe you could make some video where you try to model some tricky relationships, etc.?
finally!
Got another one coming up soon 😁
It would be better to add two conditions to the query, that is, the conditions may not be spliced into SQL
What do you mean?
@@MilanJovanovicTech
is not it better to inejct IConfiguration inside SqlConnectionFactory and get connection string inside rather than pass it as parameter? or it is better in terms of isolation to make it like this?
Sure, that also works
De Milane, imaš li link od git repositorija za ovo??
Nemam ovo, ali imam neke primere ovde: github.com/m-jovanovic/
Maybe I don't want any improvement. I just want to make a simple application. It's okay if many things are on a single page. I might not need new complications.
Sometimes improvements serve no purpose other than adding complexity. It's better to keep it simple unless necessary. If needed, we can deal with improvements.
Perhaps the person who comes after me will understand this code better if there are no improvements.
Everyone doesn't have to know everything. People have other things to do as well.
Sure
plz explain why singlton not scoped ??
Remind me, for which service exactly?
شكرا لك
You're welcome
It's all fun and games until you get enormous tables containing 100+ of columns. Is there a way of deal with them using Dapper without having to write the whole sql?
Will you always need 100 columns?
There are SPs for something like that, and you clean up the code
Unfortunately it is only half of the way. How do I call the API from my application and how do I retrieve the data or send data to the API?
You figure some things out on your own :)