{"id":15011536,"url":"https://github.com/pandatecham/be-lib-gridify-extensions","last_synced_at":"2025-04-12T03:43:38.691Z","repository":{"id":243843371,"uuid":"813599598","full_name":"PandaTechAM/be-lib-gridify-extensions","owner":"PandaTechAM","description":"Extensions for Gridify to simplify data filtering and pagination in .NET applications.","archived":false,"fork":false,"pushed_at":"2025-04-11T15:32:50.000Z","size":258,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"development","last_synced_at":"2025-04-11T16:52:33.241Z","etag":null,"topics":["efcore","extension","filters","gridify","library","linq","nuget","package","pandatech"],"latest_commit_sha":null,"homepage":"","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/PandaTechAM.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2024-06-11T11:36:36.000Z","updated_at":"2025-04-11T15:32:29.000Z","dependencies_parsed_at":"2024-11-14T11:21:00.491Z","dependency_job_id":"e15a4c32-c670-466a-874c-bb78b582ab67","html_url":"https://github.com/PandaTechAM/be-lib-gridify-extensions","commit_stats":{"total_commits":39,"total_committers":4,"mean_commits":9.75,"dds":0.5128205128205128,"last_synced_commit":"d905beb14cca3177f463ba167033a756d2f886d6"},"previous_names":["pandatecham/be-lib-gridify-extensions"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PandaTechAM%2Fbe-lib-gridify-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PandaTechAM%2Fbe-lib-gridify-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PandaTechAM%2Fbe-lib-gridify-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PandaTechAM%2Fbe-lib-gridify-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PandaTechAM","download_url":"https://codeload.github.com/PandaTechAM/be-lib-gridify-extensions/tar.gz/refs/heads/development","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248514214,"owners_count":21116899,"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","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":["efcore","extension","filters","gridify","library","linq","nuget","package","pandatech"],"created_at":"2024-09-24T19:41:13.243Z","updated_at":"2025-04-12T03:43:38.676Z","avatar_url":"https://github.com/PandaTechAM.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pandatech.GridifyExtensions\n\nWelcome to **Pandatech.GridifyExtensions**! This library extends the\npowerful [Gridify](https://github.com/alirezanet/Gridify) package, providing additional functionalities and a more\nstreamlined API for data filtering, ordering, and pagination in .NET applications.\n\n## Why Choose Pandatech.GridifyExtensions?\n\nGridify is great for dynamic querying, but incorporating it into projects can sometimes be repetitive or involve extra\nsetup. **Pandatech.GridifyExtensions** makes this process more efficient by:\n\n- **Extending Functionality:** Additional methods to handle common data filtering, ordering, and pagination scenarios.\n- **Simplifying the API:** Reducing boilerplate code, making your code cleaner and easier to maintain.\n- **Improving Integration:** Seamlessly integrates with .NET and EF Core projects, reducing the overhead of adding\n  dynamic querying to your applications.\n\n## Features\n\n- **Dynamic Filtering \u0026 Ordering:** Easily apply complex filters and ordering to your queries using simple methods.\n- **Pagination \u0026 Cursor Support:** Paginate data efficiently with support for both traditional pagination and\n  cursor-based pagination for better scalability.\n- **Custom Mappings:** Create custom property mappings for your entities to support advanced querying.\n- **Support for Encrypted Fields:** Automatically decrypt values with the provided decryptor function.\n- **Aggregation Support:** Perform common aggregate operations like sum, average, min, and max.\n\n## Installation\n\nInstall the package via NuGet:\n\n```bash\ndotnet add package Pandatech.Gridify.Extensions\n```\n\n## Setup\n\nTo enable Gridify support and register custom mapping classes, call the `AddGridify` method on the\n`WebApplicationBuilder`.\n\n```csharp\nbuilder.AddGridify(params Assembly[] assemblies);\n```\n\nYou can specify which assemblies to search for configurations. If no assemblies are provided, the current assembly will\nbe used.\n\n## Usage\n\n### Creating Mappings for Your Entities:\n\nTo efficiently filter and query your Book entity using Gridify, you need to create a mapping class that extends\n`FilterMapper\u003cT\u003e.` This class will define how each property in your entity should be mapped for filtering.\n\nHere’s an example of how to set up the Book entity and its corresponding mapping class:\n\n```csharp\npublic class Book\n{\n    public Guid BookId { get; set; } = Guid.NewGuid();\n    public string Title { get; set; }\n    public DateTime Date { get; set; }\n    public int Count { get; set; }\n    public long CountLong { get; set; }\n    public decimal CountDecimal { get; set; }\n    public ICollection\u003cBook\u003e Books { get; set; }\n    public Book OtherBook { get; set; }\n}\n\npublic class BookMapper : FilterMapper\u003cBook\u003e\n{\n    public BookMapper()\n    {\n        GenerateMappings();\n        // Map \"book-id\" to BookId property\n        AddMap(\"book-id\", x =\u003e x.BookId);\n\n        // Map \"count\" to Count property with an optional converter\n        AddMap(\"count\", x =\u003e x.Count, x =\u003e x.ToLower());\n\n        // Map \"count-long\" to CountLong property\n        AddMap(\"count-long\", x =\u003e x.CountLong);\n\n        // Map \"count-decimal\" to CountDecimal property\n        AddMap(\"count-decimal\", x =\u003e x.CountDecimal);\n\n        // Map \"other-dates\" to the Date property of the Books collection\n        AddMap(\"other-dates\", x =\u003e x.Books.Select(b =\u003e b.Date));\n\n        // Map \"other-book-id\" to the BookId property of the OtherBook property\n        AddMap(\"other-book-id\", x =\u003e x.OtherBook.BookId);\n        \n      AddDefaultOrderByDescending(\"book-id\");        \n    }\n}\n```\n\n### Adding Converters\n\nYou can specify a converter function as the third parameter in the AddMap method to transform the value before it is\nused.\nThis is useful for custom data manipulation and formatting.\n\n```csharp\npublic class DeviceFilters : FilterMapper\u003cDevice\u003e\n{\n   public DeviceFilters()\n   {\n      GenerateMappings();\n      AddMap(\"Name\", x =\u003e x.Name.ToLower(), x =\u003e x.ToLower());\n      AddMap(\"OsType\", x =\u003e x.OsType.ToLower(), x =\u003e x.ToLower());\n      AddMap(\"OsVersion\", x =\u003e x.OsVersion.ToLower(), x =\u003e x.ToLower());\n      AddMap(\"BrowserType\", x =\u003e x.BrowserType.ToLower(), x =\u003e x.ToLower());\n      AddMap(\"BrowserVersion\", x =\u003e x.BrowserVersion.ToLower(), x =\u003e x.ToLower());\n      AddMap(\"UniqueIdPerDevice\", x =\u003e x.UniqueIdPerDevice.ToLower(), x =\u003e x.ToLower());\n      AddMap(\"CreatedAt\", x =\u003e x.CreatedAt, x =\u003e x.ToUtcDateTime()); //This is must for date time fields\n      AddMap(\"UpdatedAt\", x =\u003e x.UpdatedAt, x =\u003e x.ToUtcDateTime()); //This is must for date time fields\n\n      AddDefaultOrderByDescending(\"Id\");\n   }\n}\n```\n\n### Filtering, Sorting, and Paging\n\nUse the `FilterOrderAndGetPagedAsync` method to apply filtering, sorting, and paging to your queries:\n\n```csharp\nvar pagedResponse = await dbContext.Books\n    .FilterOrderAndGetPagedAsync(new GridifyQueryModel { PageSize = 10, Page = 1 }, cancellationToken);\n```\n\nUse the `FilterOrderAndGetPagedAsync` method to apply filtering, sorting, and paging to your queries with selected\ncolumns:\n\n```csharp\nvar pagedBooks = await dbContext.Books\n    .FilterOrderAndGetPagedAsync(new GridifyQueryModel { Page = 1, PageSize = 10 }, x =\u003e new BookDto { Title = x.Title }, cancellationToken);\n```\n\n```csharp\n**Gridify QueryModel**\n\nBy default, `GridifyQueryModel` limits `PageSize` to 500 records. To remove this restriction, initialize it with\n`false`:\n\n```csharp\nvar gridifyQueryModel = new GridifyQueryModel(false) { PageSize = 10, Page = 1 };\n```\n\nAlternatively, you can set the `PageSize` to the maximum value with:\n\n```csharp\ngridifyQueryModel.SetMaxPageSize();\n```\n\n### Cursor-Based Pagination\n\nUse the `FilterOrderAndGetCursoredAsync` method for efficient, scalable cursor-based pagination:\n\n```csharp\nvar cursoredResponse = await dbContext.Books\n.FilterOrderAndGetCursoredAsync(new GridifyCursoredQueryModel { PageSize = 50, Filter=\"Title\u003eabc\"}, cancellationToken);\n```\n\nUse the `FilterOrderAndGetCursoredAsync` method for efficient, scalable cursor-based pagination with selected columns:\n\n```csharp\nvar cursoredBooks = await dbContext.Books\n    .FilterOrderAndGetCursoredAsync(new GridifyCursoredQueryModel { PageSize = 50, Filter=\"Title\u003eabc\" }, x =\u003e new BookDto { Title = x.Title }, cancellationToken);\n```\n\n### Distinct Values with Cursors\n\nGet distinct values of a specific column using cursor-based pagination:\n\n```csharp\nvar distinctValues = await dbContext.Books\n    .ColumnDistinctValuesAsync(new ColumnDistinctValueCursoredQueryModel { PropertyName = \"Title\", PageSize = 50, Filter=\"Title\u003eabc\" }, cancellationToken);\n```\n\n### Aggregation Operations\n\nPerform aggregate operations like sum, average, count, min, and max using `AggregateAsync`:\n\n```csharp\nvar aggregateResult = await dbContext.Books\n    .AggregateAsync(new AggregateQueryModel { AggregateType = AggregateType.Sum, PropertyName = \"Count\" }, cancellationToken);\n```\n\n## License\n\nPandatech.GridifyExtensions is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandatecham%2Fbe-lib-gridify-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpandatecham%2Fbe-lib-gridify-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandatecham%2Fbe-lib-gridify-extensions/lists"}