WCF Data Services OData サービスを使用するクライアント アプリケーションがあります (両方とも v5.3.0)。デフォルトの Atom Pub XML ではなく、JSON を使用してクライアント アプリケーションがサービスと通信するようにしたいと考えています。
これは、IEdmModel インスタンスを提供しなくても可能ですか? Atom 形式を使用すると、次のことが可能になります。
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;
これが JSON を使用して機能するのに対し、これは必要なものの例です。
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;
Atom でできるように、IEdmModel を指定せずに JSON 形式を使用できるようにしたいと考えています。これは可能ですか?