AutoDto 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package AutoDto --version 1.0.3
NuGet\Install-Package AutoDto -Version 1.0.3
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="AutoDto" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AutoDto --version 1.0.3
#r "nuget: AutoDto, 1.0.3"
#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.
// Install AutoDto as a Cake Addin
#addin nuget:?package=AutoDto&version=1.0.3

// Install AutoDto as a Cake Tool
#tool nuget:?package=AutoDto&version=1.0.3

AutoDto

This tool allows to auto create DTO model from BL model in compile time.

It supports different strategies for relations, such as ReplaceToIdProperty, AddIdProperty and ReplaceToDtoProperty

Setup

To use AutoDto, first install the NuGet package:

dotnet add package AutoDto
  • Declare partial DTO type like public partial SomeDto {}
  • Add attribute [DtoFrom(typeof(SomeBlType))]
  • Build project

Full simple setup:

[DtoFrom(typeof(SomeBlType))]
public partial SomeDto {}

AutoDto tool will generate partial SomeDto class with all public properties from SomeBlType.

Relation Strategies

Relation strategy means what to do with relation property during generating DTO.

Supported strategies:

  • None
  • ReplaceToIdProperty
  • AddIdProperty
  • ReplaceToDtoProperty

Usage

Set strategy in [DtoFrom] attribute after BL type.

[DtoFrom(typeof(SomeBlType), RelationStrategy.AddIdProperty)]
public partial SomeDto {}

If not specified - RelationStrategy.None will be used

None

DTO will have property on BL type

ReplaceToIdProperty

If BL relation property has Id property: DTO will have only RelationPropNameId property of BL relation Id prop type. If BlType has relation with array or enumerable - generated name will be RelationPropNameIds

❗ If no Id found in relation entity - result will be same as with None strategy

AddIdProperty

DTO will have relation type property and Id property is found

ReplaceToDtoProperty

Try find DTO, generated for RelationType and replace to RelationTypeDto.

❗ If many DTOs exists for RelationType - use [MainDto] attribute to mark which one should be used in ReplaceToDtoProperty

Ignore properties

To avoid some properties from BlType, use [DtoIgnore] attribute:

[DtoFrom(typeof(SomeBlType), RelationStrategy.AddIdProperty)]
[DtoIgnore(nameof(SomeBlType.PropName1), nameof(SomeBlType.PropName2))]
public partial SomeDto {}
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

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
2.1.0 889 6/1/2023
2.0.1 130 5/4/2023
2.0.0 159 4/26/2023
2.0.0-beta-2 124 4/24/2023
2.0.0-beta 125 4/24/2023
1.0.8 182 4/18/2023
1.0.7 162 4/18/2023
1.0.6 137 4/18/2023
1.0.5 159 4/18/2023
1.0.4 152 4/18/2023
1.0.3 178 4/18/2023
1.0.2 174 4/18/2023
1.0.1 147 4/18/2023
1.0.0 155 4/18/2023