Support for introspecting collection EntityType
tardate opened this issue · 4 comments
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.
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?
yep, that'll do the trick!
Check out v0.1.0 of ruby_odata. You can introspect all sorts of things now :)
That's great! I'll check out the new version