M# Tutorials

Learn to build .NET applications with M#. Our step-by-step tutorials will get you up-to-speed rapidly.
If you already know ASP.NET and C#, you can master M# in a week or two.

String Property

M# String is a high level representation of a text.
By adding a String property, M# will generate a standard C# string property with its XML documentation:

The creation of this property will also create the

nvarchar(200)

SQL type:

M# gives you flexibility by using some specific String attributes allowing you to change the behaviour in your C# logic or the generated SQL code.

Creation

When typing the string property, M# displays a list of different types:

  • String: Nullable.
  • String*: Mandatory.
  • String, Multiline: Multiline & Nullable.

Attributes

Capacity

Capacity is the number of characters allowed and will have an effect on the database column definition.
The generated SQL data type will be

nvarchar([CAPACITY])

.

Expected lines

Expected lines will have no effect on the database column definition or the generated C# class.
This property will tell M# what kind of text size we normally expect this property to have.
For example, for a "Description" column that we expect a few lines, as opposed to a single word, we can set it to "5", which will result in a TEXTAREA with 5 lines to be generated within UI elements.

Hash password

Hash password will have no effect on the database column definition or the generated C# class.
All passwords must be hashed before being stored in the database. If the property represents a password, set this attribute to "True" to avoid security problems.
If you need to compare a value with this password, for example for the authentication, use

"Your value".CreateHash() == this.Password

Default format string

Default format string will have no effect on the database column definition or the generated C# class.
Allows you to display a custom expression in UI Views.
Example: The format "Employee {0}" will displays "Employee Smith" if the value of the property is "Smith".

Trim values

Trim values will have an effect on the database column definition. If set to "True", M# will remove extra spaces at the beginning and the end of the value.
Example: " Smith " will be converted to "Smith".

Text pattern

Text pattern will add a validation rule to the generated C# class, but will have no effect on the database column definition.
This attribute allows you to define a new validation rule based on some frequent patterns.
Example: Email address, Internet URL, ISBN, Limited company number, Password, Social security number, Postcode, Phone number, ...