Byn.NetCore.Model
1.1.0
dotnet add package Byn.NetCore.Model --version 1.1.0
NuGet\Install-Package Byn.NetCore.Model -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Byn.NetCore.Model" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Byn.NetCore.Model" Version="1.1.0" />
<PackageReference Include="Byn.NetCore.Model" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Byn.NetCore.Model --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Byn.NetCore.Model, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Byn.NetCore.Model@1.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Byn.NetCore.Model&version=1.1.0
#tool nuget:?package=Byn.NetCore.Model&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Byn.NetCore.Model
Thư viện chứa các model và DTO dùng chung cho .NET Core applications.
Cấu trúc Models
Api
- ApiResponse: Base response model cho API
- ErrorResponse: Model cho error responses
- SuccessResponse: Model cho success responses
BaseData
- BaseEntity: Base entity với các thuộc tính chung (Id, CreatedDate, UpdatedDate...)
- AuditableEntity: Entity với audit fields
- EmailTemplate: Model cho email templates
- EmailRequest: Model cho email sending requests
- EmailConfiguration: Cấu hình SMTP
Enum
- ResponseStatus: Enum cho trạng thái response
- UserRole: Enum cho vai trò người dùng
- EntityStatus: Enum cho trạng thái entity
Pagging
- BasePaging: Base class cho pagination parameters
- PagedResult<T>: Generic model cho kết quả phân trang
- PagingRequest: Request model cho pagination
Setting
- AppSettings: Cấu hình ứng dụng
- JwtSettings: Cấu hình JWT
- DatabaseSettings: Cấu hình database
Cách sử dụng
Cài đặt
<PackageReference Include="Byn.NetCore.Model" Version="1.0.0" />
Sử dụng API Response
public async Task<ApiResponse<UserDto>> GetUser(int id)
{
try
{
var user = await _userService.GetByIdAsync(id);
return ApiResponse<UserDto>.Success(user);
}
catch (Exception ex)
{
return ApiResponse<UserDto>.Error(ex.Message);
}
}
Sử dụng Pagination
public async Task<PagedResult<UserDto>> GetUsers(PagingRequest request)
{
var query = _context.Users.AsQueryable();
var totalCount = await query.CountAsync();
var items = await query
.Skip((request.PageIndex - 1) * request.PageSize)
.Take(request.PageSize)
.ToListAsync();
return new PagedResult<UserDto>
{
Items = items,
TotalCount = totalCount,
PageIndex = request.PageIndex,
PageSize = request.PageSize
};
}
Sử dụng Base Entity
public class User : BaseEntity
{
public string Name { get; set; }
public string Email { get; set; }
// Các thuộc tính Id, CreatedDate, UpdatedDate đã có trong BaseEntity
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Byn.NetCore.Model:
| Package | Downloads |
|---|---|
|
Byn.NetCore.Framework
Byn .NET Core Framework - Common utilities and extensions for .NET Core applications |
GitHub repositories
This package is not used by any popular GitHub repositories.