Skip to content

Latest commit

 

History

History
107 lines (77 loc) · 6.54 KB

Entity-Parameter-Config.md

File metadata and controls

107 lines (77 loc) · 6.54 KB

'Parameter' object (entity-driven)

The Parameter object defines an Operation parameter and its charateristics.


Example

A YAML configuration example is as follows:

parameters: [
  { name: Id, property: Id, isMandatory: true, validatorCode: Common(EmployeeValidator.CanDelete) }
]

Property categories

The Parameter object supports a number of properties that control the generated code output. These properties are separated into a series of logical categories.

Category Description
Key Provides the key configuration.
Property Provides the Property reference configuration.
RefData Provides the Reference Data configuration.
Manager Provides the Manager-layer configuration.
Data Provides the data configuration.
WebApi Provides the Web API configuration.
gRPC Provides the gRPC configuration.

The properties with a bold name are those that are more typically used (considered more important).


Key

Provides the key configuration.

Property Description
name The unique parameter name. [Mandatory]
text The overriding text for use in comments.
† By default the Text will be the Name reformatted as sentence casing. To have the text used as-is prefix with a + plus-sign character.
type The .NET Type.
† Defaults to string. To reference a Reference Data Type always prefix with RefDataNamespace (e.g. RefDataNamespace.Gender) or shortcut ^ (e.g. ^Gender). This will ensure that the appropriate Reference Data using statement is used. Shortcut: Where the Type starts with (prefix) RefDataNamespace. or ^, and the correspondong RefDataType attribute is not specified it will automatically default the RefDataType to string.
nullable Indicates whether the .NET Type should be declared as nullable; e.g. int?. Will be inferred where the Type is denoted as nullable; i.e. suffixed by a ?. Where the .NET Type is not considered as an intrinsic type then will default to true.
default The C# code to default the value.
† Where the Type is string then the specified default value will need to be delimited. Any valid value assignment C# code can be used.
privateName The overriding private name.
† Overrides the Name to be used for private fields. By default reformatted from Name; e.g. FirstName as _firstName.
argumentName The overriding argument name.
† Overrides the Name to be used for argument parameters. By default reformatted from Name; e.g. FirstName as firstName.

Property

Provides the Property reference configuration.

Property Description
property The Property.Name within the parent Entity to copy (set) the configuration/characteristics from where not already defined.

RefData

Provides the Reference Data configuration.

Property Description
refDataType The underlying Reference Data Type that is also used as the Reference Data serialization identifier (SID). Valid options are: string, int, Guid.
† Defaults to string where not specified and the corresponding Type starts with (prefix) RefDataNamespace..
refDataList Indicates that the Reference Data property is to be a serializable list (ReferenceDataSidList).
† This is required to enable a list of Reference Data values (as per RefDataType) to be passed as an argument for example.

Manager

Provides the Manager-layer configuration.

Property Description
validator The name of the .NET Type that will perform the validation.
validatorCode The fluent-style method-chaining C# validator code to append to IsMandatory and Validator (where specified).
validationFramework The Validation framework to use for the entity-based validation. Valid options are: CoreEx, FluentValidation.
† Defaults to Operation.ValidationFramework.
isMandatory Indicates whether a ValidationException should be thrown when the parameter value has its default value (null, zero, etc).
layerPassing The option that determines the layers in which the parameter is passed. Valid options are: All, ToManagerSet, ToManagerCollSet.
† Defaults to All. To further describe, All passes the parameter through all layeys, ToManagerSet only passes the parameter to the Manager layer and overrides the same named property within the corresponding value parameter, ToManagerCollSet only passes the parameter to the Manager layer and overrides the same named property within the corresponding value collection parameter. Where using the PrimaryKey option to automatically set Parameters, and the Operation.Type is Create or Update it will default to ToManagerSet.

Data

Provides the data configuration.

Property Description
dataConverter The data Converter class name where specific data conversion is required.
† A Converter is used to convert a data source value to/from a .NET Type where no standard data conversion can be applied. Where this value is suffixed by <T> or {T} this will automatically set Type.

WebApi

Provides the Web API configuration.

Property Description
webApiFrom The option for how the parameter will be delcared within the Web API Controller. Valid options are: FromQuery, FromBody, FromRoute, FromEntityProperties, AcceptsBody.
† Defaults to FromQuery; unless the parameter Type has also been defined as an Entity within the code-gen config file then it will default to FromEntityProperties. Specifies that the parameter will be declared with corresponding FromQueryAttribute, FromBodyAttribute or FromRouteAttribute for the Web API method. The FromEntityProperties will declare all properties of the Entity as query parameters.An AcceptsBody indicates that the value will be passed in the HTTP Request Body and be handled (JSON deserialized) as a CoreEx.AspNetCore.WebApis.WebWebApiParam (default behavior for a Create or Update operation type).
webApiText The overriding text for use in the Web API comments.
† By default the WbeApiText will be the Name reformatted as sentence casing. To have the text used as-is prefix with a + plus-sign character.

gRPC

Provides the gRPC configuration.

Property Description
grpcType The underlying gRPC data type; will be inferred where not specified.