20 Captions, Prompts, Validations and Entity Attributes - chempkovsky/CS2WPF-and-CS2XAMARIN GitHub Wiki
Please take a look at the pictures below
- The first picture shown required field validation
- The second picture shown incorrect format and min length validation
- The third picture shown incorrect format and max length validation
- And the last picture shown Captions and Prompts
The question is as follows:
How CS2CS2WPF wizards know about validations, captions and prompts
The answer: wizards select information from entity attributes.
Let's take a look at the entity class
public class LitGenre
{
[Display(Description = "Row id", Name = "Id of the genre", Prompt = "Enter Genre Id", ShortName = "Genre Id")]
[Required]
public int GenreId { get; set; }
[Display(Description = "Name of the genre", Name = "Name of the genre", Prompt = "Enter Genre Name", ShortName = "Genre Name")]
[StringLength(20, MinimumLength = 3)]
[Required]
public string GenreName { get; set; }
}
Display.Name is used for the control caption
Display.Prompt is used for the control prompt
Display.ShortName is used for the table column title
Required is used for required field validation
First argument of StringLength Attribure is used for max length validation
StringLength.MinimumLength is used for min length validation
Datatype 'int' of GenreId-property is used for format validation
In addition to mentioned above there are some other attributes that are used by the wizards
- DatabaseGenerated(Identity)
- DatabaseGenerated(Computed)
- DataType(DataType.Date)
- DataType(DataType.Currency)
- DataType("toBinaryFormatter")
- Range(...)
Let's take a look at the fifth page of ModelViews wizard
it's shown that the wizard collects all attributes and saves to wizard's repozitory.