. Net Ria service data verification (7)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.