Call methods in the RIA Service

Source: Internet
Author: User
Tags hosting

Front-end interface Background:

Using system; using system. collections. generic; using system. LINQ; using system. net; using system. windows; using system. windows. controls; using system. windows. documents; using system. windows. input; using system. windows. media; using system. windows. media. animation; using system. windows. shapes; using system. servicemodel. domainservices. client; using system. collections. objectmodel; using silverlightriaservice. web; NA Mespace silverlightriaservice {public partial class mainpage: usercontrol {public mainpage () {initializecomponent (); serviceclass SC = new serviceclass (); SC. getunittype (1, "admin", datetime. now. adddays (-20), datetime. now, O => {If (O. haserror) {MessageBox. show ("error");} else {string strvalue = O. value; MessageBox. show ("direct call" + strvalue) ;}, null); SC. invokeoperation ("getunittype", typeof (Ienumerable <string>), new dictionary <string, object >{{ "unit", 1 },{ "cmdype", "admin" },{ "starttime", datetime. now. adddays (-20)}, {"endtime", datetime. now }}, true, evv =>{ if (! Evv. haserror) {var SD = evv. value; MessageBox. show ("INVOKE" + SD. tostring () ;}}, null);/* you can use the built-in observablecollection class to create a data source set in Silverlight. Because the observablecollection class implements the inotifypropertychanged interface, the inotifycollectionchanged interface is also implemented. The observablecollection class can not only implement add, remove, clear, and insert operations, but also trigger the propertychanged event. */Observablecollection <student> stulist = new observablecollection <student> (); SC. getstudentbyname ("Ye Wei", ye => {If (! Ye. haserror) {stulist = (observablecollection <student>) ye. value ;}}, null); SC. invokeoperation ("getstudentbyname", typeof (observablecollection <student>), new dictionary <string, object >{{ "name", "Ye Shuo" }}, true, shuo => {If (! Shuo. haserror) {stulist = new observablecollection <student> (Shuo. value as ienumerable <student>); List <student> sdstulist = new list <student> (Shuo. value as ienumerable <student>) ;}, null );}}}
View code

Ria service method:

Namespace silverlightriaservice. web {using system; using system. collections. generic; using system. LINQ; using system. web; using system. servicemodel; using system. servicemodel. domainservices. hosting; using system. servicemodel. domainservices. server; [enableclientaccess ()] public class serviceclass: domainservice {Public String getunittype (INT unit, string cmdype, datetime starttime, datetime endtime) {return unit + cmdype + starttime + endtime ;} public ienumerable <student> getstudentbyname (string name) {list <student> List = new list <student> (); list. add (new student () {studentname = Name, sex = "male"}); return list ;}}}
View code

Add web config:

<? XML version = "1.0" encoding = "UTF-8"?> <! -- For more information about how to configure ASP. NET applications, visit the http://go.microsoft.com/fwlink? Linkid = 169433 --> <configuration> <system. webserver> <modules runallmanagedmodulesforallrequests = "true"> <Add name = "domainservicemodule" precondition = "managedhandler" type = "system. servicemodel. domainservices. hosting. domainservicehttpmodule, system. servicemodel. domainservices. hosting, version = 4.0.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35 "/> </modules> <validateintegratedmodeconfiguration =" false "/> </system. webserver> <system. web> View code

 

Call methods in the RIA Service

Related Article

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.