I have a client application that is consuming a WCF Data Services OData service (both are v5.3.0). I'd like the client application to communicate with the service using JSON, instead of Atom Pub XML, which is the default.
Is this possible without without providing an IEdmModel instance? It's possible to do when using the Atom format:
var ctx = new DataServiceContext(_oDataSvcUri, DataServiceProtocolVersion.V3)
{
IgnoreMissingProperties = true
};
// this isn't explicitly needed, as it uses Atom by default
ctx.Format.UseAtom();
return ctx;
Whereas for this to work using JSON, this is an example of what's required:
var ctx = new DataServiceContext(_oDataSvcUri, DataServiceProtocolVersion.V3)
{
IgnoreMissingProperties = true
};
const string svcMetadata = "*insert contents of http://example.com/YourData.svc/$metadata here*";
var xmlReader = XmlReader.Create(new StringReader(svcMetadata));
IEdmModel edmModel = EdmxReader.Parse(xmlReader);
ctx.Format.UseJson(edmModel);
ctx.ResolveName = type => type.FullName;
ctx.ResolveType = typeName => Type.GetType(typeName + ", " + "MyDomainModelAssemblyName");
return ctx;
I'd like to be able to use the JSON format without specifying an IEdmModel like you can with Atom. Is this possible?