Skip to content

bbonkr/kr.bbon.EntityFrameworkCore.Extensions

Repository files navigation

kr.bbon.EntityFrameworkCore.Extensions Package

publish to nuget

Features

Sort method

Extends IQueryable interface.

Sort elements with filed name that Use OderBy, OrderByDescending, ThenBy, ThenByDescending methods.

Signature:

Sort(string fileName, bool isAscending)

Example code:

See Example project. example/Example.App

using(var ctx = new ExampleDbContext()){
    var result =ctx.Documents.Sort(nameof(Document.Content)).Sort(nameof(Document.Id), false);
}

ToPagedModel method

public class DocumentModel
{

}

public class DocumentPagedModel : PagedModel<DocumentModel>
{

}

//
var page = 1;
var limit = 10;

using(var ctx = new ExampleDbContext()){
    var result =ctx.Documents
        .Select(x => new DocumentModel
        {
            //
        })
        .ToPagedModel<DocumentModel,DocumentPagedModel>(page, limit);

    var items = result.Items; // You got paged items.
}

License

Follow the .net license and the Microsoft.EntityFrameworkCore license.