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

Поділитися
Вставка
  • Опубліковано 6 січ 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
  • Навчання та стиль

КОМЕНТАРІ • 13

  • @Kamilek96
    @Kamilek96 5 місяців тому +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  5 місяців тому +3

      just found out about this. sweet!

    • @SkyRosh
      @SkyRosh 3 місяці тому

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

  • @tarekabiramia913
    @tarekabiramia913 5 місяців тому +1

    Killing it as always man 🔥🔥
    keep going

  • @kvelez
    @kvelez 2 місяці тому

    Fascinating

  • @eatersdaily
    @eatersdaily 3 місяці тому

    We are good to go!

  • @walidaguib3944
    @walidaguib3944 3 місяці тому +2

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

  • @BDCPT-amPhiHoang
    @BDCPT-amPhiHoang 4 місяці тому

    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?

  • @maxiphobos
    @maxiphobos 6 місяців тому

    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  6 місяців тому +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 5 місяців тому

      @@TeddySmithDev Can you angular as well