ITPerformance.GenericDto
1.1.0.3
dotnet add package ITPerformance.GenericDto --version 1.1.0.3
NuGet\Install-Package ITPerformance.GenericDto -Version 1.1.0.3
<PackageReference Include="ITPerformance.GenericDto" Version="1.1.0.3" />
<PackageVersion Include="ITPerformance.GenericDto" Version="1.1.0.3" />
<PackageReference Include="ITPerformance.GenericDto" />
paket add ITPerformance.GenericDto --version 1.1.0.3
#r "nuget: ITPerformance.GenericDto, 1.1.0.3"
#:package ITPerformance.GenericDto@1.1.0.3
#addin nuget:?package=ITPerformance.GenericDto&version=1.1.0.3
#tool nuget:?package=ITPerformance.GenericDto&version=1.1.0.3
ITPerformance.GenericDto
ITPerformance.GenericDto is a lightweight and flexible NuGet package that provides generic DTO classes and interfaces to simplify request and response models in .NET applications. It's ideal for clean API design, pagination, and standardized data transfer.
✨ Features
PagedResultRequestDto: For paginated requests (e.g., page number and size)LimitedResultRequestDto: For requests with a maximum result countPagedResultDto<T>: Standardized response wrapper for paged dataIEntityDto<TKey>: Interface for DTOs with a unique identifier
📦 Installation
Install via NuGet:
dotnet add package ITPerformance.GenericDto
Or using the Package Manager:
Install-Package ITPerformance.GenericDto
🚀 Usage Example
public class Car : PagedResultRequestDto, IEntityDto<Guid>
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Make { get; set; }
}
public class Boat : LimitedResultRequestDto, IEntityDto<Guid>
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Make { get; set; }
}
Usage: 📁 API Controller
[ApiController]
[Route("api/[controller]")]
public class CarsController : ControllerBase
{
private readonly ICarRepository _carRepository;
public CarsController(ICarRepository carRepository)
{
_carRepository = carRepository;
}
[HttpGet]
public async Task<ActionResult<PagedResultDto<Car>>> GetCars([FromQuery] PagedResultRequestDto input)
{
var result = await _carRepository.GetPagedCarsAsync(input);
return Ok(result);
}
}
🔄 Pagination Utilities To streamline the implementation of paging logic, this package includes the PaginationHelper class and a set of extension methods under PaginationExtentions.
📌 PaginationHelper.ApplyPaging PaginationHelper.ApplyPaging automatically applies either full paging (Skip + Take) or simple limiting (Take) based on the request type:
✅ Example Usage in Repository
public async Task<PagedResultDto<Car>> GetPagedCarsAsync(PagedResultRequestDto inputDto)
{
var query = _cars.AsQueryable(); // "cars" can be a database or whatever returns a List of a type
// Apply paging using the helper
var pagedQuery = PaginationHelper.ApplyPaging(query, inputDto);
return new PagedResultDto<Car>
{
TotalCount = query.Count(),
Items = pagedQuery.ToList()
};
}
📄 Interfaces and Base Classes
| Name | Description |
|---|---|
IEntityDto<TKey> |
Marker interface for DTOs with an ID |
PagedResultRequestDto |
Contains PageNumber and PageSize for paginated requests |
LimitedResultRequestDto |
Contains MaxResultCount for limiting result count |
PagedResultDto<T> |
Contains TotalCount and Items for paginated response payloads |
🛠 Purpose This package helps you standardize and streamline typical API patterns like pagination and entity identification in your .NET applications. Designed to be simple, consistent, and easy to extend.
| 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. 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.0
- 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.