ModelWrapper 9.0.10

dotnet add package ModelWrapper --version 9.0.10
                    
NuGet\Install-Package ModelWrapper -Version 9.0.10
                    
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="ModelWrapper" Version="9.0.10" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ModelWrapper" Version="9.0.10" />
                    
Directory.Packages.props
<PackageReference Include="ModelWrapper" />
                    
Project file
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 ModelWrapper --version 9.0.10
                    
#r "nuget: ModelWrapper, 9.0.10"
                    
#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 ModelWrapper@9.0.10
                    
#: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=ModelWrapper&version=9.0.10
                    
Install as a Cake Addin
#tool nuget:?package=ModelWrapper&version=9.0.10
                    
Install as a Cake Tool

ModelWrapper Nuget

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 all TModel properties.
  • 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

๐Ÿ’ก 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 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.

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