ASP.NET Core Web API .NET 8 2024 - 7. PUT (Update)

Sdílet
Vložit
  • čas přidán 6. 01. 2024
  • ASP.NET Core Web API .NET 8 2024 - 7. PUT (Update)
    Github repo for course: github.com/teddysmithdev/FinS...
    Twitter: / teddysmithdev
    Github: github.com/teddysmithdev
    Linkedin: / teddy-smith-015ba61a3
  • Jak na to + styl

Komentáře • 13

  • @Kamilek96
    @Kamilek96 Před 6 měsíci +6

    Another approach would be to use: _ctx.Entry(entity).CurrentValues.SetValues(dto); instead of manual mapping :) Thanks for your effort on this series!

    • @TeddySmithDev
      @TeddySmithDev  Před 6 měsíci +3

      just found out about this. sweet!

    • @SkyRosh
      @SkyRosh Před 4 měsíci

      Why it's like you are trying to create a template of entity mapping if am confused

  • @tarekabiramia913
    @tarekabiramia913 Před 6 měsíci +1

    Killing it as always man 🔥🔥
    keep going

  • @kvelez
    @kvelez Před 2 měsíci

    Fascinating

  • @eatersdaily
    @eatersdaily Před 3 měsíci

    We are good to go!

  • @walidaguib3944
    @walidaguib3944 Před 3 měsíci +2

    why we can't use _context.Stock.update()?

  • @maxiphobos
    @maxiphobos Před 6 měsíci

    How about EF method AddOrUpdate? It significantly reduces code where you can just put entity Id into the body's DTO and solve both add/update operations in one line (if mapping is not required). But, of course, in this particular case it should be only one POST AddOrUpdate method, which is not bad, in my opinion. What do you think?

    • @TeddySmithDev
      @TeddySmithDev  Před 6 měsíci +1

      (opinion) Will work great for small project but will become a pain as app grows bigger and you have to do little logic checks on data coming in. But you may create something cool so don't let me stop you lol

    • @jayakumar2927
      @jayakumar2927 Před 6 měsíci

      @@TeddySmithDev Can you angular as well

  • @BDCPT-amPhiHoang
    @BDCPT-amPhiHoang Před 4 měsíci

    Why dont you use a dto to model mapper for update like what you did with create? Is it just because AddAsync() not accept DTO models?