Because. Net Ria service is not only provided for the Silverlight client, but also for Asp.net, win, etc.ProgramSo we often need to verify that all the data submitted by the client is valid.. Net Ria Service performs data validation before submission, which can reduce a lot of data errors and save the development cycle, and the framework is much more fresh.
1) when the new domain service class is created, the generate associated classes fro metadata will also be hooked.
Click OK to generate a file named domain service class plus. Metadata. cs. This is what we want to verify and defineCodePage.
2) open the file. We may see the corresponding database fields. Here we provide a series of data verification that you can customize.
The following is my demo code:
1: Internal sealed class usertablemetadata
2 :{
3:
4: // Metadata classes are not meant to be instantiated.
5: Private usertablemetadata ()
6 :{
7 :}
8:
9: Public entitystate;
10:
11: Public int ID;
12:
13: Public nullable <bool> online;
14:
15: Public String PWD;
16:
17: Public String roles;
18:
19: // required indicates that a value must be provided for verification.
20: [required]
21: // stringlength indicates that the length of the input string cannot exceed the specified length.
22: // I can specify a maximum of 10 characters.
23: [stringlength (10)]
24: // regularexpression is verified using a regular expression
25: [regularexpression ("[A-Z] [A-Za-z0-9] *")]
26: Public String userid;
27 :}
28 :}
In this way, when data is processed, the data must first take effect to the database through the rules you specify, so that there can be a more flexible data processing layer.