. Net Ria services user-defined functions (9)

Source: Internet
Author: User

In many cases, we may very much want to customize some methods that can be called directly by the SL end. This is very useful for the design idea of SOA, because a function completes a function, this is the most common design of SOA. Here I will introduce how. Net Ria services can customize functions in SL applications.

1. Define a method on the. NET Ria service end and return a custom class. This class must have a primary key. You can use "[Key]" to identify a field as the primary key. Use the [serviceoperation] Mark for this function, so that the sliverlgiht end will come out of this function.

 
1: [enableclientaccess ()]
 
2: public class mydomainservice: domainservice
 
3 :{
 
4: [serviceoperation]
 
5: Public myclass mytext (string userid)
 
6 :{
 
7: myclass MC = new myclass ();
 
8: MC. userid = userid;
 
9: MC. Input = userid;
 
10: Return MC;
 
11 :}
 
12 :}
 
13:
 
14: public class myclass
15 :{
 
16: [Key]
 
17: Public String userid {Get; set ;}
 
18: Public String input {Get; set ;}
 
19 :}

2. The call is quite simple. The following is a Silverlight-side call.Code

 
1: Public home ()
 
2 :{
 
3: initializecomponent ();
 
4: business. Web. Services. mydomaincontext MD = new business. Web. Services. mydomaincontext ();
 
5: var c = md. mytext ("funsl.com ");
 
6: C. Completed + = new eventhandler (c_completed );
 
7 :}
 
8:
 
9: void c_completed (Object sender, eventargs E)
 
10 :{
11: var B = (system. Windows. Ria. Data. invokeoperation <business. Web. Services. myclass>) sender;
 
12: business. Web. Services. myclass MC = (business. Web. Services. myclass) B. value;
 
13: MessageBox. Show (MC. userid + ";" + MC. Input );
 
14 :}

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.