Skip to content

Properties

The properties section allows users to create a property for an entity.

Fields

One property contains the following fields to be defined:

Name

The name of property to be created.

Requirements Rules:

  • Is Required;
  • Must not be a Reserved Keyword;
  • Must start with a letter;
  • Must contains only letters, numbers and the underline char ('_');
  • Max length of 50 chars;
  • Must be different from the entity name;

Example:

1
2
3
4
Entities:
- Name: My_First_Entity
  Properties:
  - Name: My_First_PropertyName


Type

The C# Type for the property.

Requirements Rules:

  • Is Required;
  • Must be an Allowed valid Type, except when the specified Type is another entity in current Model. See the valid Types;

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Entities:
- Name: My_First_Entity
  Properties:
  - Name: My_First_PropertyName
    Type: string # the type set is an allowed valid type

- Name: My_Second_Entity
  Properties:
  - Name: First_Entity_Instance
    Type: My_First_Entity # the type set is another entity included in model

It's possible to create collections/arrays using the syntax '[]' with these marks the model parser will treat the property as a collection of the specified type.

Example

1
2
3
4
5
6
7
8
9
Entities:
- Name: My_First_Entity
  Properties:
  - Name: My_First_PropertyName
    Type: '[string]' # the type is set as an array of strings
- Name: My_Second_Entity
  Properties:
  - Name: First_Entity_Instances
    Type: '[My_First_Entity]' # the type is set as an array of another entity included in model

In scenarios which the entities are used in relational database instances, the use of collections/arrays in model implies that the child entity must not have the 'KeyType' property nor create any relationships with another entities. The values ​​of these properties will be persisted in the database with the format 'Json' and the respective column names will have the suffix 'Json' concatenated to the property name (e.g.: My_First_PropertyNameJson), however, if you don't want that self-generated name and want to change it, use the resource specified in DbMapping - Properties.


IsNullable

Defines whether the property type is nullable. You typically use a nullable value type when you need to represent the undefined value of an underlying value type.

This approach will also be reflected in your database tables or collections, defining whether a given data can be null or not.

The default value for this field is 'false', that is, properties assume their default values ​​according to their underlying type when not filled.

To learn more about Nullable Types, see: Nullable value types (C# reference) | Microsoft Docs 🔗

Requirements Rules:

  • If 'true', the property must be a primitive type. It cannot be a nullable value type itself, for example, types by reference. See the list of allowed types which accept nullable values.

Example:

1
2
3
4
5
6
Entities:
- Name: My_First_Entity
  Properties:
  - Name: My_First_PropertyName
    Type: int # is a primitive type, accepts the nullable value type
    IsNullable: true


Auditable Properties

You can make your entity auditable, allowing you to know the date of creation and last modification of each record in the database.

To make this possible, just add the following properties to your entity:

1
2
3
4
5
6
7
Entities:
- Name: My_First_Entity
  Properties:
  - Name: CreatedUtc
    Type: DateTimeOffset
  - Name: ModifiedUtc
    Type: DateTimeOffset

Note

The name and type of the properties must be exactly as shown above, otherwise the entity will not be marked as auditable automatically.

With these properties, the entity will automatically receive the date and time of creation and modification, from our data access library, each time the data is inserted and updated. If you wish to manage this information on your own, the properties must be added with names other than those informed above. This way, the system will not manage these values and you must manipulate them through your requests.


Back to top