[英]How to import data types from RIA Services to silverlight
我正在使用RIA服務將數據傳輸到我的Silverlight應用程序,我為此服務添加了一個參考到我的Silverlight應用程序。
我有一個返回這樣的自定義類的方法
public class ReturnData
{
/// <summary>
/// detects if there is an error or not
/// </summary>
public bool Error
{
get;
set;
}
/// <summary>
/// If there is an error this contains the error
/// </summary>
public string ErrorMessage
{
get;
set;
}
/// <summary>
/// The Data
/// </summary>
public object Data
{
get;
set;
}
}
我用它來告訴我的應用程序操作中是否發生錯誤,並在錯誤或成功的情況下傳遞消息,類型對象的數據字段用於包含返回的數據,有時是字符串,整數,...或自定義對象。
問題是當我使用這樣的服務時
ServiceReference1.Service1Client s = new ServiceReference1.Service1Client();
s.GetDirectoriesCompleted += new EventHandler<ServiceReference1.GetDirectoriesCompletedEventArgs>(s_GetDirectoriesCompleted);
s.GetDirectoriesAsync(null);
/*
in s_GetDirectoriesCompleted method i use e.Result to get ReturnData object but i has none of the members implemented in the service
*/
我無法訪問實現的屬性,是否需要完成此操作。
當我在ReturnData.Data中返回自定義對象時,如何在應用程序中引用或使用它
如果我是對的,那么您正在談論WCF-RIA服務,對嗎? 如果是,那么這很簡單,您會看到,您只需要做三件事:1.如上所示,在.Web端創建一個類。 2.在您的DomainService中創建一個函數(我相信您可能已經添加了:)),其返回類型為“ ReturnData”。3.接下來,在應用程序的客戶端中,使用invoke操作來調用該函數並獲取其返回的值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.