{"id":30687660,"url":"https://github.com/minhsangdotcom/dynamic-query","last_synced_at":"2025-09-02T00:04:52.913Z","repository":{"id":309701427,"uuid":"1037237337","full_name":"minhsangdotcom/dynamic-query","owner":"minhsangdotcom","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-13T09:32:51.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-13T11:29:40.941Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/minhsangdotcom.png","metadata":{"files":{"readme":"README-NUGET.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-13T09:15:23.000Z","updated_at":"2025-08-13T09:32:29.000Z","dependencies_parsed_at":"2025-08-13T11:29:44.286Z","dependency_job_id":"5bb69588-57bd-4f11-8cc0-889dc7d286c5","html_url":"https://github.com/minhsangdotcom/dynamic-query","commit_stats":null,"previous_names":["minhsangdotcom/dynamic-query"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/minhsangdotcom/dynamic-query","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minhsangdotcom%2Fdynamic-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minhsangdotcom%2Fdynamic-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minhsangdotcom%2Fdynamic-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minhsangdotcom%2Fdynamic-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minhsangdotcom","download_url":"https://codeload.github.com/minhsangdotcom/dynamic-query/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minhsangdotcom%2Fdynamic-query/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273208777,"owners_count":25064204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-02T00:04:24.943Z","updated_at":"2025-09-02T00:04:52.863Z","avatar_url":"https://github.com/minhsangdotcom.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dynamic Query Extension\n\n### Support\n\n- Search\n- Sort\n- Filter with LHS Bracket syntax\n- Pagination with offset pagination and Cursor Pagination\n\n# How to use\n\nThe First parameter is the key word\nThe Second one is The Specific fields that You wanna search\nThe Third is how deep this could search\n\n```csharp\n\ndbContext.User\n    .Search(\"rose\",[\"name\"], 1)\n    .ToListAsync();\n\n```\n\n# Filter\n\nTo do filter in this template, we use LHS Brackets.\n\nLHS is the way to encode operators is the use of square brackets [] on the key name.\n\nFor example\n\n```\nGET api/v1/users?filter[dayOfBirth][$gt]=\"1990-10-01\"\n```\n\nThis example indicates filtering out users whose birthdays are after 1990/10/01\n\nAll support operations:\n\n| Operator      | Description                         |\n| ------------- | ----------------------------------- |\n| $eq           | Equal                               |\n| $eqi          | Equal (case-insensitive)            |\n| $ne           | Not equal                           |\n| $nei          | Not equal (case-insensitive)        |\n| $in           | Included in an array                |\n| $notin        | Not included in an array            |\n| $lt           | Less than                           |\n| $lte          | Less than or equal to               |\n| $gt           | Greater than                        |\n| $gte          | Greater than or equal to            |\n| $between      | Is between                          |\n| $notcontains  | Does not contain                    |\n| $notcontainsi | Does not contain (case-insensitive) |\n| $contains     | Contains                            |\n| $containsi    | Contains (case-insensitive)         |\n| $startswith   | Starts with                         |\n| $endswith     | Ends with                           |\n\nSome Examples:\n\n```\nGET /api/v1/users?filter[gender][$in][0]=1\u0026filter[gender][$in][1]=2\n```\n\n```\nGET /api/v1/users?filter[gender][$between][0]=1\u0026filter[gender][$between][1]=2\n```\n\n```\nGET /api/v1/users?filter[firstName][$contains]=abc\n```\n\n$and and $or operator:\n\n```\nGET /api/v1/users/filter[$and][0][firstName][$containsi]=\"sa\"\u0026filter[$and][1][lastName][$eq]=\"Tran\"\n```\n\n```JSON\n{\n  \"filter\": {\n    \"$and\": {\n      \"firstName\": \"sa\",\n      \"lastName\": \"Tran\"\n    }\n  }\n}\n```\n\n```\nGET /api/v1/users/filter[$or][0][$and][0][claims][claimValue][$eq]=admin\u0026filter[$or][1][lastName][$eq]=Tran\n```\n\n```JSON\n{\n    \"filter\": {\n        \"$or\": {\n            \"$and\":{\n                \"claims\": {\n                    \"claimValue\": \"admin\"\n                }\n            },\n            \"lastName\": \"Tran\"\n        }\n    }\n}\n```\n\nFor more examples and get better understand, you can visit\n\n[https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#filtering](https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#filtering)\\\n[https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#complex-filtering](https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#complex-filtering)\\\n[https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#deep-filtering](https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#deep-filtering)\n\n'Cause I designed filter input based on [Strapi filter](https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication)\n\n**To know how to binding from LHS to Dynamic object you could see my** [Clean Architecture Project Project](http://https://github.com/minhsangdotcom/clean-architecture)\n\n[This file help you to grab filter string query](https://github.com/minhsangdotcom/clean-architecture/blob/main/src/Contracts/Binds/ModelBindingExtension.cs)\n\n[This will help you how to binding from LHS to Dynamic object](https://github.com/minhsangdotcom/clean-architecture/blob/main/src/Application/Common/Extensions/StringExtension.LHSParser.cs)\n\n```csharp\nvar query = httpContext?.Request.QueryString.Value;\nstring[] stringQuery = ModelBindingExtension.GetFilterQueries(query);\n\nList\u003cQueryResult\u003e queries =\n        [\n            .. StringExtension.TransformStringQuery(stringQuery),\n        ];\nobject filter = StringExtension.Parse(queries);\nawait dbContext.User.Filter(filter).ToListAsync();\n\n```\n\n**I'll Update full of them for the next version.**\n\n### Sort\n\nThis example sorts users by name descending, then by age ascending when names are equal.\n\n```csharp\nawait dbContext.User.sort(\"name:desc, age\").ToListAsync();\n```\n\n### Pagination\n\nOffset\n\n```csharp\n   await dbContext.User.ToPagedListAsync(1, 10);\n```\n\nCursor\n\n- Before : The previous Cursor\n- After : The next cursor\n- Size : Size of page\n- Sort : User sort request\n- UniqueSort : the property that is unique to make the mechanism work property, the default is Id:asc\n\n\n```csharp\nawait dbContext.User.ToCursorPagedListAsync(request);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminhsangdotcom%2Fdynamic-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminhsangdotcom%2Fdynamic-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminhsangdotcom%2Fdynamic-query/lists"}