IDataServiceMetadataProvider - 实体不会显示在$ metadata中

时间:2010-03-11 10:34:33

标签: asp.net ria astoria

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

类型的实际元数据永远不会显示,不会显示错误。非常令人沮丧。任何人都有任何想法?

1 个答案:

答案 0 :(得分:0)

哼。找到。

config.SetEntitySetAccessRule(“*”,EntitySetRights.All);

初始化中缺少

,因此所有实体都被过滤掉了;)

相关问题