Specification Pattern in a .NET 8 Web API 🚀 Improving Your Repositories!

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ม.ค. 2025

ความคิดเห็น • 28

  • @nikolayrogchev9628
    @nikolayrogchev9628 ปีที่แล้ว +4

    Overall good approach, the one thing I don't like here is that we end up with many many specification classes. I think we have to make it more "composition over inheritance"

  • @hanomedia
    @hanomedia ปีที่แล้ว +1

    *Superb!, I appreciate the effort you put into making these videos*

  • @Viking251978
    @Viking251978 ปีที่แล้ว +7

    “I will not include everything here now so you don’t get scared”… yeah that ship had sailed lol

  • @rajabmuhamedrajab5128
    @rajabmuhamedrajab5128 6 วันที่ผ่านมา

    very clear thanks😊

  • @FrankTank7777
    @FrankTank7777 ปีที่แล้ว +1

    Hi Patrick, great stuff. I am really glad I came across your channel, I love the way you teach, very simple and clear. I just have two questions: So if I understand correctly now, basically instead of having a monster repository class you will have tons of smaller classes implementing each and every possible permutation of the query? And secondly, my old brain always likes to re-use code, so would it be an anti-pattern to parameterize the specifications with the filter and include and order by so you can get the filters etc. from a view passing into the controller? Any thoughts on this, or are there other patterns that could solve that problem better. Thanks again for a really good tutorial, looking forward going through all your stuff, and really interested in everything .net 8.

  • @honestcommenter8424
    @honestcommenter8424 ปีที่แล้ว +2

    Hi, can you please make a video on blazor with google auth deployed to azure? I know you have one already but that is only working locally.

  • @MohammadKomaei
    @MohammadKomaei ปีที่แล้ว +6

    I didn't understand what's the benefit

    • @kevinlloyd9507
      @kevinlloyd9507 ปีที่แล้ว +6

      It's hard to see in these examples, but you can define and reuse specifications. Imagine a particular query is used in several places and needs to be consistent. Also, you can actually unit test the specifications in isolation of your database. If that's useful to you.

    • @ebarednaxela
      @ebarednaxela ปีที่แล้ว +1

      This architecture benefits me well as I can easily create a query function in a single location that can be used by every interface and services of my API as I add more entities to it. It's like a generic repository pattern: single location, easy to read, maintain, and debug. All querying functions are in a single location. One function added to the Specification.cs will be available instantly to the entire interface and services that is mapped with the Specification object.

  • @tje316
    @tje316 ปีที่แล้ว +2

    Great stuff! I always appreciate your videos… Just curious - is there a reason why you didn’t turn the SpecificationQueryBuilder into an extension method (with just an extra ‘this’ keyword)? Wouldn’t that increase the readability a bit more? You would be able to write context.QueryWithSpecification(Expression exp)

  • @kasozivincent8685
    @kasozivincent8685 ปีที่แล้ว

    I just woke up to this, so sweet stuff. Patrick isn’t this the query object pattern described by Fowler in PoEE?

  • @mostafasalaheldin812
    @mostafasalaheldin812 ปีที่แล้ว

    Thanks, bro what if I need more than one condition in the where clause, for example, I need Employee where the name is "Patrick" and IsPresent. How to implement that here

  • @Leo-tf7gu
    @Leo-tf7gu 4 หลายเดือนก่อน

    Includes will never be null right?

  • @augustusdevree5434
    @augustusdevree5434 ปีที่แล้ว

    Patrick, great video indeed this is! Now, how could we pass the where clause value ("RPG") to the controller (also the includes and ordeby), so I want to get this and not a static specification class;
    GET /api/Game/{genre}

    • @amtate1
      @amtate1 ปีที่แล้ว

      My thoughts exactly. It seems quite wasteful to have to write specifications per each ‘type’ that could possibly be queried and also by parameter using, you kind of follow the OCP principle by making it more flexible.
      Excellent video though!

  • @alecmatias4774
    @alecmatias4774 11 หลายเดือนก่อน

    Hi Patrick, I was wondering how will you handle the ThenInclude in the expression?

    • @heischono4917
      @heischono4917 5 หลายเดือนก่อน

      @PatrickGod don't answer, it seems ....

  • @adam-xt8te
    @adam-xt8te 10 หลายเดือนก่อน

    Hey. You create instance of every Specification for each API request and these instances don't take parameters.
    Is it better to make them static or create them once at the beginning?

  • @SahilSankla
    @SahilSankla 10 หลายเดือนก่อน

    object' does not contain a definition for 'Aggregate' and no accessible extension method 'Aggregate' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference? how to remove this error

  • @MrBabumba
    @MrBabumba ปีที่แล้ว +5

    This looks like CQRS with additional steps.

  • @zimcoder
    @zimcoder ปีที่แล้ว +12

    Thanks for the videos but I think with this one we are entering into the over engineering territory .

    • @ThisNameNowTakenIs
      @ThisNameNowTakenIs ปีที่แล้ว +3

      Yeah i agree, lets build more abstraction between repository and database just seems wrong

    • @ScrotoTBaggins
      @ScrotoTBaggins ปีที่แล้ว

      Your mom is entering into the over engineering territory

  • @magashkinson
    @magashkinson ปีที่แล้ว +1

    Show later how to combine multiple specifications

  • @vasiliylu8054
    @vasiliylu8054 ปีที่แล้ว +1

    Excuse me, what is here from .Net 8?

    • @RaZziaN1
      @RaZziaN1 ปีที่แล้ว

      nothing pretty much, same can be achieved with net 5, dunno maybe with previous versions too

  • @DavidDavidov-h2c
    @DavidDavidov-h2c ปีที่แล้ว +5

    this is too much, Kiss