use*_*964 6 c# asp.net wcf-data-services visual-studio-2012
我变了
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3
Run Code Online (Sandbox Code Playgroud)
从V3到V2验证JSON输出是否为Verbose.但是,当我将其更改回V3时,输出仍然是详细的,我必须添加
?$format=application/json;odata=verbose
Run Code Online (Sandbox Code Playgroud)
为了获得JSON Light.有关如何将其恢复到正确版本的提示?
小智 0
要解决此问题,可以使用扩展部分类
namespace Project.ServiceReference
{
public partial class MyEntities : global::System.Data.Services.Client.DataServiceContext
{
public TestDirectoryEntities(string uri)
: base(new Uri(uri), DataServiceProtocolVersion.V3)
{
this.ResolveName = new global::System.Func<global::System.Type, string> (this.ResolveNameFromType);
this.ResolveType = new global::System.Func<string, global::System.Type>(this.ResolveTypeFromName);
this.OnContextCreated();
}
}
}
Run Code Online (Sandbox Code Playgroud)