开发者

IDataServiceMetadataProvider - Entities dont show up in $metadata

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.Pr开发者_开发百科imitive,
    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?


Hmpf. Found.

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜