ThrinCheck.GenericHub
1.0.6
dotnet add package ThrinCheck.GenericHub --version 1.0.6
NuGet\Install-Package ThrinCheck.GenericHub -Version 1.0.6
<PackageReference Include="ThrinCheck.GenericHub" Version="1.0.6" />
<PackageVersion Include="ThrinCheck.GenericHub" Version="1.0.6" />
<PackageReference Include="ThrinCheck.GenericHub" />
paket add ThrinCheck.GenericHub --version 1.0.6
#r "nuget: ThrinCheck.GenericHub, 1.0.6"
#:package ThrinCheck.GenericHub@1.0.6
#addin nuget:?package=ThrinCheck.GenericHub&version=1.0.6
#tool nuget:?package=ThrinCheck.GenericHub&version=1.0.6
ThrinCheck.GenericHub
A lightweight, reusable .NET library that provides common backend building blocks for modern applications, including:
- Generic Repository Pattern implementation with Entity Framework Core
- Pagination utilities
- Standardized API response models
- Enum helper extensions
- Queryable data access support
- Bulk CRUD operations
- Logging support with Microsoft.Extensions.Logging
ThrinCheck.GenericHub is designed to reduce boilerplate code and accelerate development by providing reusable infrastructure components that can be shared across multiple projects.
Features
Generic Repository
Provides a generic repository implementation for Entity Framework Core that supports:
- Create operations
- Bulk create operations
- Update operations
- Bulk update operations
- Delete operations
- Bulk delete operations
- Query by Id
- Query by expression
- Retrieve all records
- Pagination support
- IQueryable exposure for advanced querying
- Built-in logging
Pagination Utility
Provides a reusable pagination model with metadata:
- Total Items
- Total Pages
- Current Page
- Page Size
- Has Previous Page
- Has Next Page
Supports:
- IQueryable collections (database-side pagination)
- In-memory List collections
API Response Wrapper
Provides a standard response format for APIs:
{
"statusCode": 200,
"message": "Request successful",
"data": {},
"errors": []
}
This ensures consistency across all API endpoints.
Enum Extensions
Provides helper methods for retrieving:
- DescriptionAttribute values
- DisplayAttribute values
Example:
public enum UserStatus
{
[Description("Account Active")]
Active,
[Description("Account Disabled")]
Disabled
}
var description = UserStatus.Active.GetEnumDescription();
Result:
Account Active
Installation
Install via NuGet Package Manager:
Install-Package ThrinCheck.GenericHub
Or via .NET CLI:
dotnet add package ThrinCheck.GenericHub
Dependencies
The package relies on:
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="Microsoft.Extensions.Logging" />
Ensure Entity Framework Core is configured in your application.
Getting Started
1. Create Your DbContext
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(
DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
public DbSet<User> Users { get; set; }
}
2. Register Repository in Dependency Injection
services.AddScoped<
IDbRepository<User>,
DBRepositoryBase<User>>();
Or create a custom repository:
public class UserRepository
: DBRepositoryBase<User>, IUserRepository
{
private readonly ApplicationDbContext _context;
public UserRepository(ApplicationDbContext context, ILogger<DBRepositoryBase<User>> logger) : base(context, logger)
{
_context = context;
}
}
public interface IUserRepository : IDbRepository<User>
{
}
Register:
services.AddScoped<IUserRepository>, UserRepository>();
Repository Usage
Insert and Save Immediately
var user = new User
{
Id = Guid.NewGuid(),
Name = "John Doe"
};
await repository.InsertAsync(user);
Create Without Saving
Useful when implementing a Unit of Work pattern.
await repository.CreateAsync(user);
await repository.SaveChangesAsync(
CancellationToken.None);
Create Multiple Records
await repository.CreateManyAsync(users);
await repository.SaveChangesAsync(
CancellationToken.None);
Update Record
user.Name = "Updated Name";
await repository.UpdateAsync(user);
Update Multiple Records
await repository.UpdateManyAsync(users);
await repository.SaveChangesAsync(
CancellationToken.None);
Delete By Id
await repository.DeleteAsync(userId);
await repository.SaveChangesAsync(
CancellationToken.None);
Delete Entity
await repository.DeleteAsync(user);
Delete Multiple Records
await repository.DeleteManyAsync(
x => x.IsDeleted);
await repository.SaveChangesAsync(
CancellationToken.None);
Get By Id
var user = await repository.GetAsync(userId);
Get Single Record
var user = await repository.GetAsync(
x => x.Email == email);
Get All Records
var users = await repository.GetAllAsync(null);
With filter:
var activeUsers = await repository.GetAllAsync(
x => x.IsActive);
Advanced Querying
The repository exposes IQueryable support for custom queries.
var users = repository
.AsQueryable()
.Where(x => x.IsActive)
.OrderBy(x => x.Name);
Pagination
Request Parameters
Example model:
public class RequestParameters
{
public int PageNumber { get; set; } = 1;
public int PageSize { get; set; } = 10;
}
Paginating IQueryable
var query = repository
.AsQueryable()
.Where(x => x.IsActive);
var result = await repository
.GetAllPaginatedAsync(
query,
new RequestParameters
{
PageNumber = 1,
PageSize = 10
});
Paginating In-Memory Lists
var users = await repository.GetAllAsync(null);
var pagedResult = await repository
.GetAllPaginatedAsync(
new RequestParameters
{
PageNumber = 1,
PageSize = 10
},
users.ToList());
Pagination Response Structure
{
"pageNumber": 1,
"pageSize": 10,
"totalItems": 250,
"totalPages": 25,
"hasPrevious": false,
"hasNext": true,
"items": []
}
API Response Usage
Success Response
var response = APIResponse<User>.Create(
HttpStatusCode.OK,
"User retrieved successfully",
user);
Error Response
var response = APIResponse<object>.Create(
HttpStatusCode.BadRequest,
"Validation failed",
null,
new List<string>
{
"Email is required",
"Password is required"
});
Enum Helper Usage
Using DescriptionAttribute
public enum PaymentStatus
{
[Description("Payment Successful")]
Success,
[Description("Payment Failed")]
Failed
}
var description =
PaymentStatus.Success.GetEnumDescription();
Output:
Payment Successful
Using DisplayAttribute
public enum UserRole
{
[Display(Name = "System Administrator")]
Admin
}
var displayName =
UserRole.Admin.GetEnumDisplayName();
Output:
System Administrator
Logging
All repository operations are integrated with ILogger.
Examples:
User was inserted at 2026-06-03T10:00:00Z
User was updated at 2026-06-03T10:05:00Z
User was deleted at 2026-06-03T10:10:00Z
This provides audit-friendly logging for CRUD operations.
Best Practices
Use CreateAsync for Unit of Work
await repository.CreateAsync(entity);
await repository.SaveChangesAsync(cancellationToken);
Use InsertAsync for Immediate Persistence
await repository.InsertAsync(entity);
Use AsQueryable for Complex Queries
var query = repository
.AsQueryable()
.Where(x => x.IsActive);
Prefer IQueryable Pagination
Database-side pagination is more efficient than paginating in-memory collections.
Supported Frameworks
- .NET 6
- .NET 7
- .NET 8
- .NET 9
(Depending on the target framework configured in the package.)
Contributing
Contributions, feature requests, and bug reports are welcome.
If you encounter issues or have suggestions for improvements, please open an issue in the project repository.
License
Copyright © ThrinCheck.
Licensed under the applicable license specified in the repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. 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. |
-
net6.0
- Microsoft.EntityFrameworkCore (>= 6.0.33)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.6 | 128 | 6/5/2026 |