-
Notifications
You must be signed in to change notification settings - Fork 1
Server DTO
damiancosmoschapman edited this page Oct 5, 2021
·
1 revision
Home / Developer / Server Tier / DTO
DTO (Data Transfer Object) definition and example.
DTOs are used as a simple Data Transfer Object in order to hold an object corresponding to the Json parameters in the API call. Typically there is one DTO for each parameter set, however it is useful in some cases to re-use DTOs if the parameters of various API calls are similar. Where appropriate, DTO properties may be decorated with custom attributes. The constructor is used in order to populate the DTO properties with the Request parameters.
internal class Language_DTO_Create
{
[LowerCase]
public string LngIsoCode { get; set; }
public string LngIsoName { get; set; }
public Language_DTO_Create(dynamic parameters)
{
if (parameters.LngIsoCode != null)
this.LngIsoCode = parameters.LngIsoCode;
if (parameters.LngIsoName != null)
this.LngIsoName = parameters.LngIsoName;
}
}
In this case, the DTO has two properties and the constructor is used to populate the properties from the parameters. Also note that the LngIsoCode property takes the [LowerCase] custom attribute.