Adding Filtering, Sorting And Pagination To a REST API | .NET 7

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ธ.ค. 2024

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

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

    Get the source code for this video for FREE → the-dotnet-weekly.ck.page/rest-api-p2
    Want to master Clean Architecture? Go here: bit.ly/3PupkOJ
    Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt

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

      That's a hot topic in my dev team right now, we are debating if we should use SignalR or C# HTTP Listener class with and encrypted inbound port and a DNS address, our system are stand alone desktop apps and not web apps, so security is a huge factor.
      Biggest problem with SignalR route has been a reliable way to reconnect automatically :(

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

    On 13:19, you could create an IQueryable extension method that takes the sort order field and your expression and does the decision for OrderBy or OrderByDescending behind the scenes. Removes a bit of boilerplate code that you don't need to copy paste for each search endpoint in your API.

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

      I know, that could've been the next step

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

      Man You Dont Know How Valueble These Comments are And Its Great Idea im gonna Do It Rn xD

  • @kodindoyannick5328
    @kodindoyannick5328 9 หลายเดือนก่อน +1

    I've been looking for a channel like yours for a long time and now I found it. It's your channel Milan and I'm so happy. Thank you very much for your knowledge sharing. I still have to find a good mentor on the front end like you are for me on the back end 🙏🙏🙏

  • @zheniachubarov3384
    @zheniachubarov3384 2 หลายเดือนก่อน +1

    If we talking about separation of concerns and clean architecture, where am I supposed to put such PagedList?

    • @MilanJovanovicTech
      @MilanJovanovicTech  2 หลายเดือนก่อน

      Common/Shared stuff? Probably works fine

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

    Have you already done a full tutorial on your channel? I like your teaching style! I wish there is a full tutorial or even a course

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

      There's another video for CRUD endpoints

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

      @@MilanJovanovicTech I mean a full tutorial from the beginning (Include the setup). This is for us beginners 😁

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

    A few years ago I used a library for parsing OData query options called Moon.OData. I could send an OData query and the program translated it into a normal t-sql. Very simple and safe for both user and developer.
    I believe there are more such libraries nowadays. Would definitely recommend that to anyone.

  • @swift8995
    @swift8995 4 หลายเดือนก่อน

    Where should I put the PagedList model? In the domain layer or in the application?

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

    Great, in-detail tutorial!

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

    Waiting for the Dapper version too! Great video.

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

      Hah! That would actually be interesting! Adding it to my video backlog 💥

  • @Karthik-ug8ll
    @Karthik-ug8ll ปีที่แล้ว +1

    Thanks for this awesome video.I was searching from long time 😊.

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

    Your videos are SO good! Thank you for teaching me so much!

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

      Also, where did you learn these techniques? I'm curious because I feel it's difficult to find good resources and tutorials that use industry standards unless you work in the industry. Or what books do you recommend to learn more about these techniques in depth?

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

      1. I do work in the industry 😅 At least I did until this year, now I try to stay in the loop with consulting.
      2. Pluralsight has a lot of good resources for .NET, to be honest. Courses from Kevin Dockx about APIs cover all of this in much more detail.

  •  ปีที่แล้ว +15

    We want the Dapper version too.

    • @MilanJovanovicTech
      @MilanJovanovicTech  ปีที่แล้ว +9

      I see there's demand for it, already added it to my backlog 😁

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

    Bravo doktore 🤝

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

    The issue on 06:00 is it because of value object thing having setup with valueConverters? I run into this issue a few times.

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

    Thanks for sharing this insightful, in all my api projects i use rye same logic for paging, filtering and sorting. For the pagination i return an object that contains items page number and page size as you did, however instead of returning a boolean HasNextPage or HasPreviousPage, i return string which are url for the previous and next pages already prepared (when i'm one the first page, previous page is null and if i'm in the last page next page is gonna be null )so in case one of clients of my api is working on a batch for frtching data url are already prepared by the api 😃
    Thanks for sharing i really like your helpful content

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

      HATEOAS, that's smart! I didn't want to introduce that as I thought it would be too much, but I might just prepare that for the next video

    • @mohamedal-qadeery6530
      @mohamedal-qadeery6530 ปีที่แล้ว

      Hello that's really good can you share the code for it ?

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

    Excellent as usual Milan 👌

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

    I had to create something similar but the backend DB was Mongo so I had to use projection, and for the search I used reflection to get the Data Annotation for the BsonElement name and type, the documents had over 150 fields ... It would be nice to add reflection to this tutorial to avoid hard coding the name of the properties, maybe using JsonProperty annotation??? Thanks for the great tutorial

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

    Excellent video! Really helpful! Thanks for sharing! by the way, can you explain in a short video format the record and sealed modifiers from your perspective and it's importance the documentation not consider optimization benefits. Thanks

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

    Milan, this was a very useful video tutorial. thx a lot

  • @valcron-1000
    @valcron-1000 8 หลายเดือนก่อน

    At 21:02 aren't you performing the query twice at the DB level? Once to get the `totalCount` and a second one to get `items`? If so, how can we avoid this?

    • @MilanJovanovicTech
      @MilanJovanovicTech  8 หลายเดือนก่อน +1

      This is a typical issue with this type of pagination. You could write SQL and a batched query that would fetch both values in one round trip.

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

    I loved the Expression with switch to cover the which column to sort by, in my project I have the same amount of search choices I want to cover, so I'm using if else statements, can you please show case or at least right here as a respond an Expression with switch that is used in Where() instead of OrderBy(). I tried it but I'm messing something and i can't get it to work. Thanks a lot for the video, it helped a lot

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

    It seems like a good tutorial but I am having difficulty following your architecture and stuff about record and sku. Are there any prior videos that I need to watch? This has been happening to me for quite a few videos so any help in that will be very appreciated.

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

    I highly suggest you determine a maximum page size and use that instead of what the client is requesting if their pagesize exceeds your maximum. :)
    Also, I think I like returning the pagination information in headers, rather than in the response payload.

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

      Whoops, missed to mention that! But yeah, that's important to consider. (Can't say I never tried to harass some APIs by seeing if they had a max_page_size on the backedn 😅)

    • @shahryarsaljoughi6073
      @shahryarsaljoughi6073 7 หลายเดือนก่อน

      How would having pagination information within hdeaders benefit? Is it common?

    • @pilotboba
      @pilotboba 7 หลายเดือนก่อน

      @@shahryarsaljoughi6073 I prefer keeping paging out of the query string which I reserve for filters.

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

    Thank you for covering those topics which are helpful in handling performance issues.
    On filtering, if the table has multiple columns, then the number of parameters may grow. is there a generic way to easily achieve it.
    On pagination, if the result fits in 5 pages, the client should call the API for 5 times. So, the end query will be executed 5 times by considering the page number. will it not affect the sql performance

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

      For filtering u need to use reflection and build your own - use queryable, there is no in-built solution. For pagination u should add some kind of limit parameter which could be set to number representing numbers of records on each page (Skip + Take)

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

      You can achieve most of it with reflection, and there's even a cool library out there called Dynamic.Linq

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

    This is good stuff. EF is fine when returning simple entities from the DB. At 13:46 I would have taken the refactoring a little further and eliminate the "8-liner" (as I like to to call those if..else pairs that simply assign a variable) with the ternary operator.
    I'm not a fan the PageList stuff, returning the TotalCount is a very expensive choice with, IMO, limited value. Whether there is a previous or next page is of even less value. (E.g. I know I just got page 1 so I don't really need the server to tell me there isn't a previous page and for reasonable page sizes (say 20) 95% of the time I can tell there is no next page because the count of results returned is < pageSize). I prefer the simplicity of just returning the set of results but I guess it is down to your specific use cases.

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

      >> returning the TotalCount is a very expensive choice
      An extra 86ms on my desktop machine with a 1000000 row table

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

      @@davearkley7014 Were you filtering a text value using a contains predicate? How many concurrent users are also demanding an extra 86ms of DB servers' time? That's huge right?

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

      I had the same idea reg ternary operator.

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

      I would need to check if EF converts the CountAsync into SELECT COUNT(*) FROM (

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

      @@nothingisreal6345 No that still will not be "ok". Pretty sure it does do that and without any criteria the DB could respond with internal stats it maintains, it won't have to actually count records.
      However, if you are using say a Name Like '%' + term + '%' its going have to do a table scan, and search each string. Considering the use case for this feature is pretty weak to start with, I personally don't include this in my designs.

  • @mahmoudabdel-moughiss9950
    @mahmoudabdel-moughiss9950 ปีที่แล้ว +1

    thans alot, this was very useful .🙏🙏

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

    Does the select hurt performance of the take, skip, or count async? Calling ToListAsync is when the queryable is actually executed but how does it know to reorder the operations in a performant way?

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

      No, EF doesn't execute anything until the ToList call - it's only then that everything is assembled into a SQL query so it know how to re-order them to achieve the optimal result

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

    Thank you for the quality content I have a question. For sorting and searching why didnt you use reflection to search or sort in every column. Also if you add new fields you dont need to add new contains to the where part.

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

      I find this approach more explicit, so that's why. You could've also done it with reflection, but it would've been a lot more cumbersome.

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

      normally you apply indexes to search columns

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

    Hi! again, I'm glad with your nice explanation!
    But I have a cuple of questions, what about create queries (with pagination as you show us) with multiples tables in our database?
    and by the other hand, what do you think about the EF against the Dapper performance?

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

      Use whichever ORM you like 😁
      And what about create endpoints?

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

    I was expecting something more generic like Sieve for automatic pagination sorting and filtering.
    Or OData or graph

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

      Sometimes it's worthwhile to know the fundamentals

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

    Great video as usual. Any chance of an Odata tutorial?

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

      I haven't used it in Production, so I'll see if I can find some time to research it

  • @junior.santana
    @junior.santana ปีที่แล้ว +2

    Is there a standard way for adding specific/complex filters? For example, filtering by a date interval or a price range. Creating this in a generic way to be reused in several endpoints

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

      Search for odata

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

      Unless you'll be using it in quite a few endpoints, it's probably not worth it implementing a custom abstraction

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

      LinqKit has a PredicateBuilder. We add attributes to our search parameter properties that defines what and how comparisons should be applied on what on the search result. Ours handles standard ones, exact, like, ranges, enum matching, lists, nullables, etc. Should be possible to find a start on google.

    • @the-nasim
      @the-nasim ปีที่แล้ว

      ​@@alanbreeeeDoes OData work with the Minimal API?

  • @swift4511
    @swift4511 2 หลายเดือนก่อน

    Can I use the CreateAsync method of the PagedList with the repository, build the query inside method, and then pass it to the PagedList? Or is it better to move CountAsync() and ToListAsync() out of the PagesList to maintain separation of concerns?

    • @MilanJovanovicTech
      @MilanJovanovicTech  2 หลายเดือนก่อน

      Sure, you can just pass in the pre-computed data to PagedList

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

    How do you rate Biarity Sieve for Sorting , Filtering and Pagination? although it has some challenges for VO or complex types

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

      I can't rate it since I never used it 🤷‍♂️

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

      I love that library and other one which i use is Gridify

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

    Why you didn’t use graphql with EF Core ?

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

    Great! Thanks Milan ❤

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

    Could you show us how to implement the sorting if we are using generic classes and we don't know the class attributes before runtime?

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

      You'd need a "smart" mechanism to standardize it, and you'll probably end up using reflection or something similar

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

    17:22 "by incrementing the page *number" 😉

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

    How would you do dynamic select/projection?

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

      I'd say only if you're not used to the second approach. We can argue for both approaches, if we want to

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

    Thanks for the tutorial and great video, Is there a series for this video?

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

      Yes:
      1) th-cam.com/video/nE2MjN54few/w-d-xo.html
      2) th-cam.com/video/X8zRvXbirMU/w-d-xo.html
      3) th-cam.com/video/59Ce4O3J7Do/w-d-xo.html

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

      @@MilanJovanovicTech thank you milan

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

    I have a question, you are getting all the products with context.Products, if I have 5000 items it gets them all and then you are applying the filtering. Therefore the filter would not make sense because the objects are being loaded into memory and then the paging is applied.
    I have a doubt, thank you

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

      No, the first is just an IQueryable and it doesn't touch the database until we call ToListAsync

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

      Milan, but when I debug the IQueryable already has all the results, without the TolistAsync, why does this happen?, I am waiting for your answer, thanks

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

      @@cristhianjuliancubides6269 Probably because debugger triggers the evaluation of the iqueryable so you can see the results. Are you sure you don't click something like "show me the results (this will force the enumeration)"?

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

    OMG you're the man! Thanks

  • @phuongtran-qh5kq
    @phuongtran-qh5kq ปีที่แล้ว +1

    Hi Milan, tks for the video. It would be great if you could make a video on the Expression that you created? I could not wrap my head around that.😂

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

      Ah, sorry about that. It's an EF trick I use from time to time. I'll see what I can do

    • @phuongtran-qh5kq
      @phuongtran-qh5kq ปีที่แล้ว

      @@MilanJovanovicTech thanks Milan. What is the keyword of this Expression? i wanna search it up first

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

    Great video, but I have a question: is it possible to reference the DBContext from the application layer with a clean architecture?

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

      It's possible - but it "breaks" the architecture

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

      Good question @joseantonio
      Please can you explain what you mean by break the architecture. @MilanJovanovicTech
      I recently worked on a project where I fetched data as queryables. I did this by creating the interface for each entities' repository in the application layer and then implementing it in the infrastructure layer.
      Do you have a better way to achieve this.

    • @mahmoudsayed133
      @mahmoudsayed133 3 หลายเดือนก่อน

      I have the same consideration,
      So i was creating an interface in application layer *IApplicationDbContext* and it contains all DbSet's and methods like saveChanges and others that you need in application layer,
      then let your DbContext implements IApplicationDbContext and add it to dependency injection
      And then you can use IApplicationDbContext through application layer.

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

    Really helpful 😊
    Which machine are you using for editing and recoding? Specs
    Thanks 👍

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

      Ryzen 7-based machine, RTX 3060, pretty solid setup.

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

      @@MilanJovanovicTech are you using liquid cooling or air cooling for pc ?

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

    Could you make implicit operator for Sku, so we will remove type casting and just use Sku where string is expected?

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

      EF has to know that you want it to be a string and not a Sku :/

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

      A better approach in my opinion since it is a value object is to use a EF Converter... Sku.HasConversion... I think it is.

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

    Thanks for the great video, I've followed your clean architecture course which is great too. I'm building a project off the back of that and wondering how you've structured the IApplicationDbContext interface here to use directly in the handler as oppose to a repository interface as the DbContext is in the infrastructure layer. How is this interface being registered in the DI container? Do you have any code examples of what that interface could look like?

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

      services.AddDbContext(_rest of ef config_);
      You can use this overload 👆

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

    Hi Milan, thank for the video.
    are you going to refactor the sorting method to be extension method and generic?
    var list =await context
    .Users
    .OrderDescendingByField(nameof(User.Name)) // OrderByField for asc
    .ToListAsync();

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

      Yeah, could be doable - not planning on it. But perhaps with reflection.

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

      System.Linq.Dynamic.Core makes it possible to just order by a string, a little easier but will need to check if the column is valid in some other way,

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

    Hi, what if in page 2 and tried to search an item available in page 1 do I still get that item? Or every search is need to reset the pageNumber to 1?

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

      You'd get what matches that search - but on page 2

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

    Ahhhh .... you are amazing

  • @swift8995
    @swift8995 4 หลายเดือนก่อน

    Can I return the PagedList with a list of domain models from the repository and map it in a query handler to a PagedList of DTOs to send as a response?

  • @khanfaizan05
    @khanfaizan05 7 หลายเดือนก่อน

    Wonderful. Thanks ❤

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

    Thank you, very helpful. Nice clean coding as well 👍

  • @ДаниїлТерентьєв
    @ДаниїлТерентьєв ปีที่แล้ว +1

    Thank you for useful video! I was wondering, whether we are able to create generic method for sorting not only for the specific class, but for all entites. Is it possible to do in correct way? Because I tried and it looks like sh!t)

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

      Yes you can! What does it look like?

    • @ДаниїлТерентьєв
      @ДаниїлТерентьєв ปีที่แล้ว

      @@MilanJovanovicTech for now, I used specification pattern. Was inspired by your previous video). In my test assignment I receive sorting and paging via query parameters, which can be null. Therefore I decided to create specification inheritor from base specification. And IN RUNTIME apply different things, like sorting by column name and so on to it. It is not predefined like you shown in the video. What do you think about this. Is this a good approach? Thank you for reply :)

  • @PGWalkthrough
    @PGWalkthrough 11 หลายเดือนก่อน +1

    can you post the result query generated by EF? It would be nice to know how its being done in Sql Server.

    • @MilanJovanovicTech
      @MilanJovanovicTech  11 หลายเดือนก่อน +1

      Will try if I can find some time - but nothing special, just your standard WHERE/ORDER BY/OFFSET query

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

      @MilanJovanovicTech thanks for your reply. I am actually trying to implement pagination and sorting in sql query but i dont seem to find the best approach. The main problem is sorting as they mainly recommend to have a massive switch statement with a case for every column in the table or i have to write a dynamic query but have the risk of sql injection as the column name param is coming from front end. Thanks.

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

    Is there a way to set up filtering and orderby to be like pagedlist generic?

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

      With paged list it's easy to fetch current page / count all records. But how would you build generic filtering with different entity types?
      I'm sure we can come up with some abstraction to provide the desired filter and sorting. But is it worth it?

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

      @@MilanJovanovicTech Yes was wondering about that since orderby and filtering dont look if i may say appealing to me but as you say its not worth it to go that deep in abastraction

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

    Any thoughts on creating a tutorial for Cursor Pagination or any other types along with explaining the benefits of the same? As always great videos. 😇

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

    You could do sorting using dynamic linq
    public static IQueryable SetOrdering(this IQueryable query,
    string orderColumn, string orderingDirection)
    {
    if (string.IsNullOrEmpty(orderColumn))
    {
    return query;
    }
    return query.OrderBy($"{orderColumn.Trim()} {orderingDirection.Trim().ToLower()}");
    }
    Ofc column and sort order would be validated in validation step

  • @alang39564
    @alang39564 9 หลายเดือนก่อน

    How would you approach a case where you need to paginate child entites of an aggregate?

    • @MilanJovanovicTech
      @MilanJovanovicTech  9 หลายเดือนก่อน +1

      How would that work from an API consumer perspective?

    • @alang39564
      @alang39564 9 หลายเดือนก่อน

      @@MilanJovanovicTech let's say you have a Shop (aggregate root) which has N employees and you want to get api/shop/{shopId)/employees?page=1&pageSize=10

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

    Sorting input can be a bit better using enum string.

  • @milanlimbu4417
    @milanlimbu4417 4 หลายเดือนก่อน

    This theme looks beautiful can you provide me the name of it... and Thank for the tutorial Learned alot from you

  • @MaksymVasylyshyn-dx8hy
    @MaksymVasylyshyn-dx8hy 7 หลายเดือนก่อน

    How about use approach which use only 3 models it's: PaginationOptions, SortingOptions, FilteringOptions and use enum instead string in case sorting for example, it's make code more cleaner and remove reducant parameter, I wish to know how to implement this thank, you, I can share the post in LinkedIn where I find it

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

    With Dapper?

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

    Why not GrapaQL?

  • @zheniachubarov3384
    @zheniachubarov3384 2 หลายเดือนก่อน

    Could you please show how to unit test internal classes?

  • @wolfgang5945
    @wolfgang5945 8 หลายเดือนก่อน

    How to view MVC with it 🤔? I was trouble

  • @SureshKumar-rz7dn
    @SureshKumar-rz7dn ปีที่แล้ว +1

    I use a nuget package called sieve to does this .

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

      Oh cool, let me check that out

    • @SureshKumar-rz7dn
      @SureshKumar-rz7dn ปีที่แล้ว

      @@MilanJovanovicTech Yes , please let us know your thought about this 🙂

  • @idanqwe1
    @idanqwe1 8 หลายเดือนก่อน

    will that work with .net 6?

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

    Source code needed

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

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

    with OData, you dont need to do all implementation by youself.

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

    Actually what you did there is very bad. The much better solution in to make thing more generic by create more interfaces and base query handlers. Also, way you doing sorting is ugly. You can just use reflection and make it work with whatever object you like without any problem. I created such generic mechsnism in my project using cqrs and efcore and developers who are using it loves that you can add new lists in just minute by inheriring some base generic classess

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

      I'm still a junior engineer, don't be so rude

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

      @@MilanJovanovicTech you are junior? Though you are senior who create content for less experienced devs. Sorry then.

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

      @@MilanJovanovicTech Don't mind him! Your content was pretty good!
      No reflection means better speed, base classes and generic interfaces may be needed if you were to craft a general-purpose lib such as Sieve or AutoQueryable, but what you demonstrated simply allows anyone aiming at this goal to get started and generalize any way they'd like
      What's more, promoting heavily layered and generic architecture is at the very least debatable (Heard of the heated debate between cmuratori and uncle Bob of "clean code" fame? One comes from the native video game world where performance is paramount, the other is a book-author consultant who goes full with DI, virtual dispatching and OO patterns). From bare-bone C-like code to 50-layer architectures there's a middle ground, but I must admit that, age helping, I'm leaning more and more towards the less abstraction side (and I've been professionally using C# for 20y now)
      Simply said, there's nothing in this video you'd have to feel ashamed of. Even as a senior dev, I found inspiration here for my own use cases!

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

      @@OlivierDALET Thanks a lot, I appreciate it. I'm not really a junior, just messing with OP a little. I do tend to not overcomplicate my videos, and let the viewer find what value he can and take it from there into their own implementation. If they choose to make it more complex and entirely generic, that's great for them.

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

    Too much coding to deliver such a simple standard feature. I have a library that does this and much more without any coding.

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

      Sometimes it's good to know the fundamentals, instead of reaching for a library for everything

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