Can I define an EntityType but not make it available as a Feed?

71 Views Asked by At

I'm using Odata/Olingo v2. I have several Entity Types defined including Product and Category. A Product can have many Categories.

I would like to ONLY make Products available as a Feed/Resource. I thought I could accomplish this by defining a Category Entity Type and Association but not adding the Categories EntitySet and AssociationSet to the EntityContainer. I also created a NavigationProperty between Product and Category.

This appears to be valid EDMX, at least Olingo's EdmxProvider.parse() does not object. However, when I post a Product with a collection of Categories to the Products feed Olingo throws an exception from EdmEntityContainerImplProv.getAssociationSet() because it expects to find an AssociationSet for Categories

Is there a way to accomplish this in OData/Olingo v2?

Edit: It's not an option to make Category a ComplexType because I need to have a collection of them and that's not possible in OData/Olingo v2

1

There are 1 best solutions below

0
On

I am not familiar with olingo implementations, so cant point you to methods/whatever.

But in general: if you want an entity to be accessible as a set (be it as /Product('123')/ToCategories or just /CategorySet), you need the according EntitySet in your metadata and in your implementation.

You can, however, limit your implementation to only respond when used via navigation property.

As an example: on an Abap implementation, the method implementing category get_entityset has the information, that it is accessed via navigation property from another entity (or even a path) including keys. Here, you can throw an exception or just return an empty set, if you decide you don’t want to offer direct access to /CategorySet