ModelWrapper 9.0.10
dotnet add package ModelWrapper --version 9.0.10
NuGet\Install-Package ModelWrapper -Version 9.0.10
<PackageReference Include="ModelWrapper" Version="9.0.10" />
<PackageVersion Include="ModelWrapper" Version="9.0.10" />
<PackageReference Include="ModelWrapper" />
paket add ModelWrapper --version 9.0.10
#r "nuget: ModelWrapper, 9.0.10"
#:package ModelWrapper@9.0.10
#addin nuget:?package=ModelWrapper&version=9.0.10
#tool nuget:?package=ModelWrapper&version=9.0.10
ModelWrapper 
ModelWrapper is a C# (.NET) library designed for Web API projects.
It simplifies the use of request and response ViewModels by providing a unified way to work with your domain model (TModel).
Author: รtalo Silveira
License: MIT
Company: BAYSOFT
๐ Overview
In RESTful applications, developers usually define separate classes for entities, requests, and responses.
ModelWrapper provides a generic foundation for these models, allowing you to:
- Create request ViewModels inheriting from
WrapRequest<TModel>, reusing all base entity properties. - Create response ViewModels inheriting from
WrapResponse<TModel>, exposing specific fields in a strongly-typed way. - Avoid code duplication and keep your domain and API models consistent.
- Centralize shared logic and metadata between request and response models.
โ Main Features
WrapRequest<TModel>โ Base class for request ViewModels inheriting allTModelproperties.WrapResponse<TModel>โ Base class for response ViewModels with extendable typed properties.- Built for RESTful APIs in C#.
- Available on NuGet:
ModelWrapper(version 9.0.10.0). - Can be extended or combined with AutoMapper or other mapping frameworks.
๐ Installation
Using NuGet Package Manager
Install-Package ModelWrapper -Version 9.0.10.0
Using .NET CLI
dotnet add package ModelWrapper --version 9.0.10.0
๐ป Example Usage
// Domain model
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
}
// Request ViewModel
public class ProductRequest : WrapRequest<Product>
{
public string Notes { get; set; }
}
// Response ViewModel
public class ProductResponse : WrapResponse<Product>
{
public string Category { get; set; }
}
// Controller
[HttpPost]
public ActionResult<ProductResponse> Create([FromBody] ProductRequest req)
{
var product = new Product { Name = req.Name, Price = req.Price };
// Save entity, etc.
var resp = new ProductResponse();
resp.MapFrom(product); // depending on the libraryโs implementation
resp.Category = "Example";
return Ok(resp);
}
๐ Documentation
- Repository:
https://github.com/isilveira/ModelWrapper - NuGet Package:
https://www.nuget.org/packages/ModelWrapper - License:
MIT
๐ก Benefits
- Eliminates duplication between entities and ViewModels.
- Provides consistent request/response structure.
- Simplifies API maintenance and refactoring.
- Works seamlessly with mapping tools such as AutoMapper.
- Ideal for clean architectures and layered applications.
๐ง Best Practices
- Use WrapRequest<TModel> for input models and WrapResponse<TModel> for output models.
- Keep business rules and validation logic outside the wrappers.
- If you use AutoMapper, configure profiles that recognize wrapper types.
- Use wrappers to ensure consistency across multiple services and controllers.
๐ค Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request directly on the repository.
Suggestions and feature improvements are appreciated.
๐งพ License
This project is licensed under the MIT License.
You are free to use, modify, and distribute it, provided you credit the original author.
| 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. |
-
net9.0
- Enums.NET (>= 5.0.0)
- Microsoft.AspNetCore.Mvc.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.10)
- Newtonsoft.Json (>= 13.0.4)
- System.Linq (>= 4.3.0)
- System.Reflection.Emit (>= 4.7.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ModelWrapper:
| Package | Downloads |
|---|---|
|
BAYSOFT.Abstractions
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.0.10 | 185 | 10/27/2025 |
| 8.0.6.8 | 337 | 3/1/2025 |
| 8.0.6.7 | 196 | 2/15/2025 |
| 8.0.6.6 | 328 | 10/7/2024 |
| 8.0.6.5 | 194 | 10/6/2024 |
| 8.0.6.4 | 204 | 7/13/2024 |
| 8.0.6.3 | 186 | 7/11/2024 |
| 8.0.6.2 | 237 | 6/28/2024 |
| 8.0.6.1 | 262 | 6/23/2024 |
| 8.0.6 | 236 | 6/20/2024 |
| 8.0.3 | 259 | 6/18/2024 |
| 8.0.2 | 336 | 6/18/2024 |
| 8.0.1 | 208 | 6/11/2024 |
| 8.0.0 | 210 | 6/2/2024 |
| 7.0.0 | 212 | 6/2/2024 |
| 6.0.0 | 186 | 6/2/2024 |
| 5.0.0 | 187 | 6/2/2024 |
| 4.0.17 | 251 | 4/27/2024 |
| 4.0.16 | 256 | 4/25/2024 |
| 4.0.15 | 240 | 4/25/2024 |
| 4.0.14 | 216 | 4/25/2024 |
| 4.0.13 | 371 | 3/18/2024 |
| 4.0.12 | 255 | 2/22/2024 |
| 4.0.11 | 222 | 2/7/2024 |
| 4.0.10 | 279 | 2/3/2024 |
| 4.0.9 | 215 | 2/1/2024 |
| 4.0.8 | 442 | 12/12/2023 |
| 4.0.7 | 229 | 12/11/2023 |
| 4.0.6 | 254 | 11/28/2023 |
| 4.0.5 | 266 | 11/23/2023 |
| 4.0.4 | 274 | 11/18/2023 |
| 4.0.3 | 252 | 11/12/2023 |
| 4.0.2 | 453 | 9/2/2023 |
| 4.0.1 | 543 | 4/22/2023 |
| 4.0.0 | 627 | 3/25/2023 |
| 3.0.0 | 845 | 1/30/2022 |
| 3.0.0-beta | 337 | 11/19/2021 |
| 2.1.1 | 534 | 6/10/2021 |
| 2.1.0 | 1,388 | 1/18/2020 |
| 2.0.2 | 781 | 12/6/2019 |
| 2.0.1 | 733 | 12/4/2019 |
| 2.0.0 | 724 | 11/20/2019 |
| 1.1.0 | 879 | 3/22/2019 |
| 1.0.1 | 850 | 3/20/2019 |
| 1.0.0 | 806 | 3/20/2019 |
| 1.0.0-beta | 1,046 | 6/28/2018 |
Response properties selection is now fully dynamic