Building a Dapper CRUD API From Scratch In .NET 7 - For Beginners

Поделиться
HTML-код
  • Опубликовано: 15 ноя 2024

Комментарии • 98

  • @MilanJovanovicTech
    @MilanJovanovicTech  Год назад +1

    Want to master Clean Architecture? Go here: bit.ly/3PupkOJ
    Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt

  • @kodindoyannick5328
    @kodindoyannick5328 9 месяцев назад +2

    Clean and efficient! Thank you Milan.

  • @haroldoribeirogomes7103
    @haroldoribeirogomes7103 Год назад +9

    It would be good make a new video improving this API, spliting it in layers (Repository, Services, ...) and implementing unit tests.

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад +3

      Perhaps, but this is enough for a beginner to get started

    • @mrt7948
      @mrt7948 Год назад +1

      Please take it to the next level

  • @nettoaoquadrado
    @nettoaoquadrado Год назад +2

    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!

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад +1

      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. ❤️

  • @dahlw
    @dahlw Год назад +1

    Didn't know about the option for route groups, thanks for showing us that . Would love to see how you would unit test this.

  • @abdifatahAnnaati
    @abdifatahAnnaati Год назад +1

    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
      @MilanJovanovicTech  Год назад +1

      I despise Automapper 😁

    • @abdifatahAnnaati
      @abdifatahAnnaati Год назад

      @@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)

  • @mahmoudalaskalany
    @mahmoudalaskalany Год назад +1

    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❤

  • @Kingside88
    @Kingside88 Год назад +2

    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?

  • @Leonidn1972
    @Leonidn1972 Год назад +1

    Thaks a lot. Can I creating a Database with Code First in minimal API project ?

  • @MrBodyPower
    @MrBodyPower Год назад +3

    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.

    • @abdifatahAnnaati
      @abdifatahAnnaati Год назад

      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.

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад

      It can be a singleton also - just not if you want to store and reuse the current connection inside.

  • @samuniv987
    @samuniv987 Год назад +1

    What would be the difference between creating a controller vs using minimal api if we are moving the code from program.cs?

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад +2

      Will you have 200 endpoints in Program.cs?
      Minimal APIs are more performant

  • @tattooineste
    @tattooineste Год назад +1

    Superb. Thank you.

  • @mahditalebi1770
    @mahditalebi1770 Год назад +1

    What do you think of relationships using dapper and having nested objects in C# based on the relationships?

  • @ahmedbasha9653
    @ahmedbasha9653 Год назад

    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.

  • @emanuelrodriguez3155
    @emanuelrodriguez3155 Год назад +3

    How can we merge Clean Arquitecture and DDD with Dapper instead of EF Core?

    • @EekChocolate
      @EekChocolate Год назад +1

      Put all your SQL logic in repositories that get called by either Application layer services or CQRS commands and queries.

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад +1

      It'a definitely harder, since there is no UoW. One option is the Snapshot pattern.

    • @emanuelrodriguez3155
      @emanuelrodriguez3155 Год назад

      thx i do a little research on that@@MilanJovanovicTech

  • @hussainimca
    @hussainimca 6 месяцев назад

    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.

    • @MilanJovanovicTech
      @MilanJovanovicTech  6 месяцев назад

      I doubt such a video exists

    • @roshanthapa25
      @roshanthapa25 5 месяцев назад

      Hi brother, I am also in the same situation like you, have you found any good resources?

  • @marshallnyamadzawo8553
    @marshallnyamadzawo8553 Год назад +1

    Are there no vulnerabilities, like SQL Injection?

  • @johnormaric3350
    @johnormaric3350 Год назад +1

    Did you use Dapper here both to connect to the database and to execute APIs?

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад

      I think the answer is yes (from my understanding of your question)

  • @adeni4359
    @adeni4359 Год назад +1

    Please do more videos like this where we see you write code from the beginning

  • @lautaroseverino1464
    @lautaroseverino1464 4 месяца назад

    what's the theme you are using in visual studio? i like it

  • @ibrahimgirisken8945
    @ibrahimgirisken8945 11 месяцев назад

    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?

  • @georgekopadze791
    @georgekopadze791 Год назад +1

    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
      @MilanJovanovicTech  Год назад

      Where else would they live? 😁

    • @georgekopadze791
      @georgekopadze791 Год назад

      @@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

  • @sunzhang-d9v
    @sunzhang-d9v Год назад

    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

  • @TrappedInAVoid
    @TrappedInAVoid Год назад +3

    Really good explanation, however I feel like this Dapper thing wanting literal TSQL strings is really insecure and hellish to maintain in the future

    • @ryadean
      @ryadean Год назад

      You can easily use Stored Procedures with Dapper too if you prefer to not have TSQL littered about in your code.

    • @TheGravyMonster
      @TheGravyMonster Год назад

      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.

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад

      Not if you usr parameters

  • @unkn0wnrge189
    @unkn0wnrge189 Год назад +1

    Why did you pick up dapper now instead EF? Are you having issues with speed?

    • @azad2096
      @azad2096 Год назад +1

      yes, thats the reason Dapper is being preffered, the performance. EF is too slow but more complex

    • @unkn0wnrge189
      @unkn0wnrge189 Год назад

      @@azad2096 In past I knew EF was bad in performance but the new version I think are fine.

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад

      No, I want to talk about different options

  • @Website-Content-Creator
    @Website-Content-Creator Месяц назад

    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

  • @health_doc
    @health_doc Год назад +1

    You should also do a video using dapper rainbow

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад

      Interesting, will explore some more 🤔

    • @health_doc
      @health_doc Год назад

      @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

  • @ShivamSingh-gu1hn
    @ShivamSingh-gu1hn Год назад +1

    which theme are you using?

  • @joseronaldo7917
    @joseronaldo7917 Год назад

    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!

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад +1

      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.

  • @yogij17
    @yogij17 Год назад

    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?

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад +1

      As a query parameter? Seems doable

    • @yogij17
      @yogij17 Год назад

      @@MilanJovanovicTech Thanks for your reply 🙂👍 What should be the best practice for such scenario.🤔 I dont want long if else statements

  • @michaels7366
    @michaels7366 Год назад

    but what is the advantage of dapper over entity framework?

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад +1

      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.

  • @matthewrossee
    @matthewrossee Год назад

    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
      @MilanJovanovicTech  Год назад +1

      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

    • @matthewrossee
      @matthewrossee Год назад

      @@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.?

  • @kimrobertrozen5609
    @kimrobertrozen5609 Год назад +1

    finally!

  • @sunzhang-d9v
    @sunzhang-d9v Год назад

    It would be better to add two conditions to the query, that is, the conditions may not be spliced into SQL

  • @andreyz3133
    @andreyz3133 Год назад +4

    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?

  • @RebelSouls
    @RebelSouls 5 месяцев назад

    De Milane, imaš li link od git repositorija za ovo??

    • @MilanJovanovicTech
      @MilanJovanovicTech  5 месяцев назад

      Nemam ovo, ali imam neke primere ovde: github.com/m-jovanovic/

  • @oneminutecoder
    @oneminutecoder 6 месяцев назад

    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.

  • @minaemad-c7y
    @minaemad-c7y 8 месяцев назад

    plz explain why singlton not scoped ??

  • @mouradaissani8957
    @mouradaissani8957 Год назад +1

    شكرا لك

  • @docbrown2045
    @docbrown2045 Год назад

    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?

    • @MilanJovanovicTech
      @MilanJovanovicTech  Год назад

      Will you always need 100 columns?
      There are SPs for something like that, and you clean up the code

  • @uwejadick4550
    @uwejadick4550 Год назад +1

    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?