ming-tsai / AutoSort.NetCore

Use entity attributes for default sorting

Home Page:https://www.nuget.org/packages/AutoSort.NetCore/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NetCore.AutoSort build nuget Quality Gate Status Conventional Commits License: MIT

Recently, I have a project that made with ef core, and every time I added some property I have to create a new condition for soring it, so I want to sort the entity with a string or with some mark that could be used as default sorting, so I created this solution to manage this problem.

I was guiding by ZZZ Projects's System.Linq.Dynamic.Core

Install the package

Using dotnet cli

dotnet add package AutoSort.NetCore

Or package manager

Install-Package AutoSort.NetCore

How to use?

Set default sort attribute

When applying the sort but didn't pass parameter ordering it will take configuration of model.

Import the library

using NetCore.AutoSort;

Adding attibute to model properties

public Hero
{
    // this will be the last sort and ascending
    [Sort(2)]
    public int Id { get; set; }
    // this will be sort first one and descending
    [Sort(SortDirection.Descending)]
    public string Name { get; set; }
    // this will sort in second one ascending
    [Sort(1)]
    public string History { get; set; }
}

More example in AutoSort.Example

License

This project is licensed under the MIT License - see the LICENSE file for details

About

Use entity attributes for default sorting

https://www.nuget.org/packages/AutoSort.NetCore/

License:MIT License


Languages

Language:C# 100.0%