Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for introspecting collection EntityType #11

Closed
tardate opened this issue Nov 13, 2011 · 4 comments
Closed

Support for introspecting collection EntityType #11

tardate opened this issue Nov 13, 2011 · 4 comments
Labels

Comments

@tardate
Copy link

tardate commented Nov 13, 2011

I am using ruby_odata for generalised data discovery (see http://rgovdata.com), so ideally I want to rely 100% on metadata for access.

Perhaps I have missed something, or don't know the OData spec well enough, but while I can access the collections (@collections) and the entity types (@classes) and entity metadata (@class_metadata), it seems only a matter of convention that relates the collection to the associated entity. i.e. using just ruby_odata, I can't know in advance what entity will be returned from a given collection (but I can make a good guess).

e.g.
Given the following (a simplified version of this):

<Schema Namespace="SNBModel">
  <EntityType Name="ATM">
    ..
  </EntityType>
</Schema>
<Schema Namespace="ServicesWebRole.EntityDataModels.SNB">
  <EntityContainer Name="SNBEntities" m:IsDefaultEntityContainer="true">
    <FunctionImport Name="ATMSet" EntitySet="ATMSet" ReturnType="Collection(SNBModel.ATM)" m:HttpMethod="GET"/>
    <EntitySet Name="ATMSet" EntityType="SNBModel.ATM"/>
  </EntityContainer>
</Schema>

..then @collections is the array of EntitySet names from the EntityContainer collection, and @classes is the array of EntityType names with associated @class_metadata. In this example, "ATMSet" is a collection of "ATM" entities, but I only know that by linguistic inference.

There are two parts to what I'd like to be able to do:

  • given an OData::Service instance
  • then I can get the collections it offers (i.e. @collections, but exposed with a public getter)
  • given a collection
  • then I can get the entity type it contains / will return

The collection information is in the EntitySet definition (EntityType) but is currently not pulled/exposed by ruby_odata. I currently hack around these limitations, but it would be nice to have this formally supported by ruby_odata.

@visoft
Copy link
Owner

visoft commented Nov 13, 2011

I like the idea of being able to get information about the service from within ruby_odata.

Check out the develop branch. I have exposed collections on an OData::Service. The result is a hash where the key is the collection name and the value is the EntityType (as a string directly from the EDMX). Does this help you?

@tardate
Copy link
Author

tardate commented Nov 13, 2011

yep, that'll do the trick!

@visoft
Copy link
Owner

visoft commented Dec 8, 2011

Check out v0.1.0 of ruby_odata. You can introspect all sorts of things now :)

@visoft visoft closed this as completed Dec 8, 2011
@tardate
Copy link
Author

tardate commented Dec 11, 2011

That's great! I'll check out the new version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants