使用架构http://schemas.microsoft.com/ado/2007/06/edmx生成OData $ metadata [英] Generating OData $metadata with the schema http://schemas.microsoft.com/ado/2007/06/edmx

查看:61
本文介绍了使用架构http://schemas.microsoft.com/ado/2007/06/edmx生成OData $ metadata的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用ODataLib 5.6.1生成这样的OData元数据文档时:

When I use ODataLib 5.6.1 to generate an OData metadata document like this:

var eModel = new Microsoft.Data.Edm.Library.EdmModel();
.... 
...WriteMetadataDocument()
....

我得到以下xml:

edmx文档1 :

<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx" Version="3.0">
...
</edmx:Edmx> 

但是元数据(

However this metadata (http://services.odata.org/V3/OData/OData.svc/$metadata) has a different schema:

edmx文档2 :

<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
...
</edmx:Edmx> 

如何生成类似于文档2的元数据?我的动机是许多OData客户端(例如Visual Studio的添加服务参考")似乎无法识别文档1.

How can I generate metadata looking like the document 2? My motivation is that many OData clients (e.g. Visual Studio's "Add Service Reference") don't seem to recognize the document 1.

推荐答案

过一会儿,我发现了窍门(使用SetEdmVersion):

After a while I figured out the trick (using SetEdmVersion):

var eModel = new Microsoft.Data.Edm.Library.EdmModel();
...
eModel.SetEdmVersion(new Version(1, 0));

这篇关于使用架构http://schemas.microsoft.com/ado/2007/06/edmx生成OData $ metadata的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆