ASP.NET Core Web API - 5. Repository Pattern & Dependency Injection Explained

Sdílet
Vložit
  • čas přidán 29. 06. 2024
  • ASP.NET Core Web API 2022 - 5. Repository Pattern & Dependency Injection Explained
    UML Diagram: drive.google.com/file/d/1EbYY...
    Github Repo For This Project: github.com/teddysmithdev/poke...
    Twitter: / teddysmithdev
    Github: github.com/teddysmithdev
    Linkedin: / teddy-smith-015ba61a3
    Website: www.teddysmith.io
  • Jak na to + styl

Komentáře • 64

  • @FoxFireImr
    @FoxFireImr Před 2 lety +1

    Thank you, you're really darn great. I look forward to seeing the rest of your videos :)

  • @abdulmlaikalomayri727
    @abdulmlaikalomayri727 Před 10 měsíci

    As always great videos from teddy smith. Thank you so much.

  • @afelixalves
    @afelixalves Před 2 lety +8

    Great tutorial! Nice advanced (and correct) structure made simple. With so many bad approaches to API tuturials out there, this is the one to follow! Keep the great work and thanks for sharing it...

  • @SamuelFatunmbi
    @SamuelFatunmbi Před 7 měsíci

    Thank you very very much, Teddy. I love the way you teach.

  • @monat_son
    @monat_son Před 10 měsíci

    thanks Teddy, quality content!

  • @macctosh
    @macctosh Před rokem +14

    for larger projects its Controller -> Services -> Repositories

  • @kaydenangel3742
    @kaydenangel3742 Před rokem

    Heish man you are the best👏👏

  • @hafidazer1634
    @hafidazer1634 Před 5 měsíci

    This one was abit rough but got the 'get' call working, I guess I have to watch the video few more times to understand the details and again thank you very much Teddy for taking the time to make such great content. Looking forward to the other videos of this series. God bless

  • @user-bp7wn8el2j
    @user-bp7wn8el2j Před rokem

    it's really great !

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

    good explanation of decoupled code. thanks t

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

    Love your videos brother

  • @parthsavliya4441
    @parthsavliya4441 Před 2 lety +1

    God !

  • @boopfer387
    @boopfer387 Před rokem +5

    8:45 you say an ICollection is only read only - I believe you are referring to IEnumerable, ICollection you can add / remove but only to the end. IList has index so edit anyplace.

    • @TeddySmithDev
      @TeddySmithDev  Před rokem +4

      Did not know that. Thank you for commenting.

  • @tilmandr7415
    @tilmandr7415 Před 7 měsíci

    Hey Teddy,
    thank you so much for this Tutorial. As an Software Developer that is familiar with the basic concepts of things like DI etc. it is easy to follow. I could imagine, that it could be hard to follow, if you dont have that background knowledge. Maybe you could link Videos that go a little deeper in that concepts in the sections. :)
    Greets Tilman

    • @TeddySmithDev
      @TeddySmithDev  Před 7 měsíci +2

      I made new blog posts on the topic, but my next course that I’m releasing will explain these topics better. Thanks for watching!

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

    10:37 IMPORTANT INFO. Services explained

  • @henrik3098
    @henrik3098 Před rokem

    thanks man

    • @TeddySmithDev
      @TeddySmithDev  Před rokem

      No prob thanks for watching and commenting 👍

  • @lofto8363
    @lofto8363 Před 10 měsíci +1

    i don't know what i am doing, but im lovin it

  • @oanaghicajanucristina
    @oanaghicajanucristina Před 9 měsíci

    great videos! Liked and subscribed, but i have a question. Why did you use mapper? why you did not use logger? and why you didn't use service classes?

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

      I’ve always found that going the extra and creating your own mappers can save time because you never have to debug them and can always easily change to meet needs

  • @raggardy
    @raggardy Před 2 lety +3

    Hi Teddy. With IEnumerable and ICollection, can you use either or is it convention to use one and stick with it? Cheers

    • @TeddySmithDev
      @TeddySmithDev  Před 2 lety +6

      Use IEnumerable when you need to filter data. ICollection has more features like .length and CRUD actions.

  • @junlapunete1602
    @junlapunete1602 Před rokem

    Can I ask what font are you using?

  • @leafmagi2796
    @leafmagi2796 Před 2 lety +1

    you really care the plural form of pokemon! Actually the full name is pocket monster, maybe the plural form is pokcet monsters :D

  • @etiel
    @etiel Před 2 lety +1

    Do you use reshaper? It's very nice when it's ghosting the completion for you

    • @TeddySmithDev
      @TeddySmithDev  Před 2 lety

      No but I'll check it out. Resharper is on my to do list of things to do. Thanks for suggestion.

  • @eihabelbrgaty8909
    @eihabelbrgaty8909 Před rokem

    Hi Teddy Million thanks for this tutorials ... I stack with ModelState Error does not exist in the current context

    • @yugant
      @yugant Před 10 měsíci +2

      i was stuck at the same issue . Your controller needs to inherit from ApiController (or Controller) . public class PokemonController : ControllerBase

    • @supa_space
      @supa_space Před 10 měsíci

      @@yugant
      Thank you for this tip, I was stuck here for hours😂

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

    Hi Teddy, I'm trying this video today and I'm getting a 404 Undocumented Error: Not Found in the place where you see the all the Pokemon. All other server responses look to be correct. Would you have an idea on where I could be going wrong? Thanks in advance!

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

    Hi Sir, I am getting this error.
    System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: WebAPI.Interfaces.IOrderHeaderRepository Lifetime: Scoped ImplementationType: WebAPI.Repository.OrderHeaderRepository': Unable to resolve service for type 'WebAPI.Data.DataContext' while attempting to activate 'WebAPI.Repository.OrderHeaderRepository'.)'
    Please help

  • @Raj-iz9uz
    @Raj-iz9uz Před rokem

    Error : Showing in Swagger : No Operations defined in spec!

  • @tylerb5803
    @tylerb5803 Před měsícem

    Fun fact, if your scrolling down because it's not working when you click run. Don't forget to build your solution first.

  • @alidahud337
    @alidahud337 Před rokem

    ​ @Teddy Smith Hi, if it doesn't give me the contents of the database, what should I do? it's giving me back: id: 0 articletext: "string" etc.

    • @TeddySmithDev
      @TeddySmithDev  Před rokem

      That is strange. Maybe you are using method with no default ie. first() and not firstOrDefault()?

    • @alidahud337
      @alidahud337 Před rokem

      @@TeddySmithDev Where?

    • @alidahud337
      @alidahud337 Před rokem

      @@TeddySmithDev even though i successfully seeded some data into the DB

    • @alidahud337
      @alidahud337 Před rokem

      @@TeddySmithDev I found my issue but now another error: System.FormatException: String 'FalseData Source=DESKTOP-HGUF4HF' was not recognized as a valid Boolean., Which is inside of my connection string, but this statement raises the error: return _context.qbitArticles.OrderBy(q=>q.id).ToList();

  • @AlThePal78
    @AlThePal78 Před rokem

    Do you use this pattern a lot I was told .NET was a repository pattern or something like that so why do this ? what you think about that

  • @omerucansu2569
    @omerucansu2569 Před 10 měsíci

    Hi sir, Why don't you use the async method

    • @TeddySmithDev
      @TeddySmithDev  Před 10 měsíci

      No real reason. Just didn’t add it at the time.

  • @evilsanta8585
    @evilsanta8585 Před 8 měsíci

    So youre bringing in the entire databse in. isn't that slower when the database becomes huge

    • @TeddySmithDev
      @TeddySmithDev  Před 8 měsíci

      Ef Core only builds SQL queries and doesn’t really bring any data besides what you ask

  • @baileymorgan9986
    @baileymorgan9986 Před rokem

    I am getting a CORS error when completing this video. Unsure why as I am not using CORS yet. Any ideas? I have tried multiple browsers.

    • @TeddySmithDev
      @TeddySmithDev  Před rokem

      You need to turn cors off explicitly. Look at my GitHub for examples.

    • @baileymorgan9986
      @baileymorgan9986 Před rokem

      @@TeddySmithDev No where in your github (for this project) do I see references to cors. I am not turning it on explicitly so I am not sure how to turn it off explicitly

  • @yusufkaandemirbas4451
    @yusufkaandemirbas4451 Před 10 měsíci

    Is it an entry level course? By brain blowed up

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

      May want to check intro to C# video series on my homepage

  • @sylgeekhome
    @sylgeekhome Před 7 měsíci

    Why pokemon not called pokemons inside dbset?

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

      This is the debate of the century lmao. What is the true plural form of Pokémon??? 🤣

  • @rifathossain328
    @rifathossain328 Před rokem

    i know OOP but i am getting lost here kinda confusing .

  • @Shadowplayification
    @Shadowplayification Před rokem +1

    I'm a little late to the party, I know, but when i try to run my code, I get this Exception:
    System.InvalidOperationException: 'Action 'PokemonReviewApp.Controllers.PokemonController.GetPokemons (PokemonReviewApp)' does not have an attribute route. Action methods on controllers annotated with ApiControllerAttribute must be attribute routed.'
    What can I do to fix this?

    • @Shadowplayification
      @Shadowplayification Před rokem

      The Exception gets thrown at app.MapControllers(); in the Program.cs class.

    • @TeddySmithDev
      @TeddySmithDev  Před rokem +2

      You might need to check to see if controller annotation is in your controller code

    • @juricamihin7524
      @juricamihin7524 Před rokem

      just add
      using RouteAttribute = Microsoft.AspNetCore.Mvc.RouteAttribute;