【发布时间】:2012-02-21 20:00:13
【问题描述】:
背景:我有一个带有 Silverlight 应用程序的 WCF 数据服务,该应用程序当前正在使用 atom pub xml。我想使用 JSON 来减小有效负载的大小。 我读到您可以使用以下代码从服务 webget 获取 JSON:
WebClient wc = new WebClient();
wc.Headers["Accept"] = "application/json";
我可以修改 DataServiceQuery 调用或 localContext.BeginExecute(用于 WebGet)的标头吗?
// WCF Data Services Query Proxy
DataServiceQuery<T> query = filterExpression as DataServiceQuery<T>;
// Execute the ASYNC query against the model
query.BeginExecute(new AsyncCallback((iar) =>
{ ...});
或
// Create new context with the WCF service to force only save this entity
VisiconnEDM localContext = new VisiconnEDM(new Uri(entityServiceURL, UriKind.Absolute));
// execute the query asynchronously
localContext.BeginExecute<T>(urlQuery,(IAsyncResult iar) =>{ ...},null);
【问题讨论】:
标签: json silverlight wcf-data-services