谁能告诉我如何使用 Simple.Odata.Client 以 xamarin 形式从 OData 服务中检索数据?
我尝试通过以下方式:
在便携式项目中
public App()
{
GetDocument();
}
public async void GetDocument()
{
String result = await ODataServiceAgent.GetDocuments(skipCount);
}
在 OData 服务调用中
public static async Task<string> GetDocuments(int skipCount)
{
string json = string.Empty;
try
{
var client1 = new ODataClient(new ODataClientSettings(ServiceConstant.sURL_Base, new System.Net.NetworkCredential(ServiceConstant.NCUserName, ServiceConstant.NCPassword))
{
IgnoreResourceNotFoundException = true,
//OnTrace = (x, y) => Console.WriteLine(string.Format(x, y)),
});
string commands = string.Format(ServiceConstant.sURL_WholeDataByPagging, ServiceConstant.servicePaggingTopCount, skipCount);
IEnumerable<IDictionary<string, object>> configs = client1.FindEntriesAsync(commands).Result;
List<IDictionary<string, object>> configList = ((List<IDictionary<string, object>>)configs.ToList());
json = JsonConvert.SerializeObject(configList);
}
catch (Exception ex)
{
string excepstionMessage = ex.Message;
}
return json;
}
虽然实际调用是使用“FindEntriesAsync”行发生的,但它没有响应