IDataServiceMetadataProvider - 实体未显示在 $metadata 中

发布于 2024-08-25 03:05:20 字数 2498 浏览 11 评论 0原文

我正在尝试编写我们自己的 RIA 服务提供程序来公开我通过 ODBC 访问的服务器中的数据。我遵循 http://blogs.msdn.com/alexj/archive/2010/03/02/creating-a-data-service-provider-part-9-un-typed.aspx

我已经编写了自己的 IDataServiceMetadataProvider / IDataServiceQueryProvider 对,并且我所做的事情没有出现任何错误。

我正在放入这样的资源集:

ResourceType tableType = new ResourceType(
    typeof(Dictionary<string, object>),
    ResourceTypeKind.EntityType,
    null,
    "Martini",
    table_name,
    false
);
tableType.CanReflectOnInstanceType = false;
var prodKey = new ResourceProperty(
    "Key",
    ResourcePropertyKind.Key |
    ResourcePropertyKind.Primitive,
    ResourceType.GetPrimitiveResourceType(typeof(int))
);
prodKey.CanReflectOnInstanceTypeProperty = false;
tableType.AddProperty(prodKey);
var prodName = new ResourceProperty(
    "Name",
    ResourcePropertyKind.Primitive,
    ResourceType.GetPrimitiveResourceType(typeof(string))
);
prodName.CanReflectOnInstanceTypeProperty = false;
tableType.AddProperty(prodName);

_MetaDataProvider.AddResourceType(tableType);
_MetaDataProvider.AddResourceSet(new ResourceSet(table_name, tableType));

我看到传入的请求用于枚举资源集。我在断点处检查它们,并且资源集和类型以及所有属性都在那里。

尽管如此,我得到的输出是:

  <?xml version="1.0" encoding="utf-8" standalone="yes" ?> 
- <service xml:base="http://localhost:2377/MartiniData.svc/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2007/app">
- <workspace>
  <atom:title>Default</atom:title> 
  </workspace>
  </service>

对于 $metadata 版本:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?> 
- <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
- <edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0">
- <Schema Namespace="Martini" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2007/05/edm">
  <EntityContainer Name="Martini" m:IsDefaultEntityContainer="true" /> 
  </Schema>
  </edmx:DataServices>
  </edmx:Edmx>

类型的实际元数据永远不会显示,也不会显示错误。相当令人沮丧。有人有什么想法吗?

I am trying to write our own RIA services provider to expose data from a server that I access via ODBC. I follow th eguidelines set out at http://blogs.msdn.com/alexj/archive/2010/03/02/creating-a-data-service-provider-part-9-un-typed.aspx

I have written our own IDataServiceMetadataProvider / IDataServiceQueryProvider pair and get no errors on what i do.

I am putting in a resource set like this:

ResourceType tableType = new ResourceType(
    typeof(Dictionary<string, object>),
    ResourceTypeKind.EntityType,
    null,
    "Martini",
    table_name,
    false
);
tableType.CanReflectOnInstanceType = false;
var prodKey = new ResourceProperty(
    "Key",
    ResourcePropertyKind.Key |
    ResourcePropertyKind.Primitive,
    ResourceType.GetPrimitiveResourceType(typeof(int))
);
prodKey.CanReflectOnInstanceTypeProperty = false;
tableType.AddProperty(prodKey);
var prodName = new ResourceProperty(
    "Name",
    ResourcePropertyKind.Primitive,
    ResourceType.GetPrimitiveResourceType(typeof(string))
);
prodName.CanReflectOnInstanceTypeProperty = false;
tableType.AddProperty(prodName);

_MetaDataProvider.AddResourceType(tableType);
_MetaDataProvider.AddResourceSet(new ResourceSet(table_name, tableType));

I see the requests coming in for enumerating the resource sets. I check them there in a breakpoint, and the resource set and the type is there, with all properties.

Still, the output I get is:

  <?xml version="1.0" encoding="utf-8" standalone="yes" ?> 
- <service xml:base="http://localhost:2377/MartiniData.svc/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2007/app">
- <workspace>
  <atom:title>Default</atom:title> 
  </workspace>
  </service>

And for the $metadata version:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?> 
- <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
- <edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0">
- <Schema Namespace="Martini" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://schemas.microsoft.com/ado/2007/05/edm">
  <EntityContainer Name="Martini" m:IsDefaultEntityContainer="true" /> 
  </Schema>
  </edmx:DataServices>
  </edmx:Edmx>

The actual metadata for the types never shows up, no error is shown. pretty frustrating. Anyone any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

才能让你更想念 2024-09-01 03:05:20

哼。成立。

config.SetEntitySetAccessRule("*", EntitySetRights.All);

初始化时缺失,因此所有实体都被过滤掉;)

Hmpf. Found.

config.SetEntitySetAccessRule("*", EntitySetRights.All);

was missing in the initialization, so all entities were filtered out ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文