【问题标题】:IDataServiceMetadataProvider - Entities dont show up in $metadataDataService MetadataProvider - 实体未显示在 $metadata 中
【发布时间】:2010-03-11 10:34:33
【问题描述】:

我正在尝试编写我们自己的 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>

类型的实际元数据永远不会显示,也不会显示错误。很令人沮丧。有人知道吗?

【问题讨论】:

    标签: asp.net ria astoria


    【解决方案1】:

    哼哼。找到了。

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

    在初始化中丢失了,所以所有的实体都被过滤掉了;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-16
      • 1970-01-01
      • 2015-01-25
      相关资源
      最近更新 更多