Luizanac.QueryExtensions.Abstractions
1.0.1
See the version list below for details.
dotnet add package Luizanac.QueryExtensions.Abstractions --version 1.0.1
NuGet\Install-Package Luizanac.QueryExtensions.Abstractions -Version 1.0.1
<PackageReference Include="Luizanac.QueryExtensions.Abstractions" Version="1.0.1" />
paket add Luizanac.QueryExtensions.Abstractions --version 1.0.1
#r "nuget: Luizanac.QueryExtensions.Abstractions, 1.0.1"
// Install Luizanac.QueryExtensions.Abstractions as a Cake Addin #addin nuget:?package=Luizanac.QueryExtensions.Abstractions&version=1.0.1 // Install Luizanac.QueryExtensions.Abstractions as a Cake Tool #tool nuget:?package=Luizanac.QueryExtensions.Abstractions&version=1.0.1
Luizanac.QueryExtensions
Simple and clean LINQ extensions library for .NET that adds sorting, filtering, and pagination functionality to EntityFramework.
You can start just by adding "Luizanac.QueryExtensions". But if you only want EFCore dependencies in projects that access databases, you can use "Luizanac.QueryExtensions.Abstractions" on other projects and all will be fine 😃
Luizanac.QueryExtensions
Install-Package Luizanac.QueryExtensions
OR
dotnet add package Luizanac.QueryExtensions
Luizanac.QueryExtensions.Abstractions
Install-Package Luizanac.QueryExtensions.Abstractions
OR
dotnet add package Luizanac.QueryExtensions.Abstractions
Examples
All following examples consider a Client class.
public class Client
{
public Guid Id {get; private set; }
public string Name { get; private set; }
public string Email { get; private set; }
public int Age { get; private set; }
}
OrderBy
To use order by extension, you will need to pass "property, asc/desc" (You can use first level navigation properties to "address.number, asc/desc", this will access Address property on Client and then Number on Address).
var sort = "age,asc";
var clients = await dbContext.Clients.AsNoTracking().OrderBy(sort).ToListAsync();
//this example will return all cleints classified by their ascending age
var sort = "name,desc";
var clients = await dbContext.Clients.AsNoTracking().OrderBy(sort).ToListAsync();
//this example will return all cleints classified by their descending name
Paginate
To use paginate extension, you only need to pass the page and then your page size
var paginatedData = await dbContext.Clients.AsNoTracking().Paginate(1, 3);
//This will return a IPagination<IList<Client>> and in Data property you can access your list of objects.
var clients = paginatedData.Data;
Here you can see IPagination properties 😃
public interface IPagination<T>
{
/// <summary>
/// The paginated data
/// </summary>
T Data { get; set; }
/// <summary>
/// The total pages
/// </summary>
int TotalPages { get; set; }
/// <summary>
/// The total data count
/// </summary>
int TotalDataCount { get; set; }
/// <summary>
/// The current page number
/// </summary>
int CurrentPage { get; set; }
/// <summary>
/// The number of datas to get
/// </summary>
int Size { get; set; }
/// <summary>
/// The previous page number
/// </summary>
int PrevPage { get; set; }
/// <summary>
/// The next page number
/// </summary>
int NextPage { get; set; }
}
Filter by properties
To use filter extension, you will ned to pass a string "{property}{operator}{data}" with your conditions separated by commas (Like order by extension, you can use first level navigation properties too).
below you can see all supported operators
Operator | |
---|---|
== |
Equals |
!= |
Not equals |
> |
Greater than |
>= |
Greater than or equal to |
< |
Less than |
<= |
Less than or equal to |
@= |
Contains |
!@= |
Does not Contains |
_= |
Starts with |
!_= |
Does not Starts with |
and here you can see an using example
var filters = "age>=16,email@=hotmail.com,name_=h";
var clients = await dbContext.Clients.AsNoTracking().Filter(filters).ToListAsync();
//This will filter all clients by age greather than or equal to 16, email contains hotmail.com and name starts with h.
you can use all extensions together
var sort = "age,asc";
var filters = "age>=16,email@=hotmail.com,name_=h";
var paginatedData = await dbContext.Clients.AsNoTracking()
.Filter(filters)
.OrderBy(sort)
.Paginate(1, 3);
License
Luizanac.Extensions is licensed under Apache 2.0.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.