This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
WebAPI 2 makes it really simple for controller actions to support OData query. All you need to do is decorate an action with [Queryable] if it returns IQueryable<T>. For example,
Now, if you add OData $filter to request URL,
you get filtered results:
However, there is a subtle issue if T is a LightSpeed Entity. You cannot filter on its Id field. The action will throw an exception on such filters.
My observation is that Id field is not defined in Product itself, but inherited from its base class, Entity<T>. But I can't make sense out of the observation. Is this a bug, or a feature? |
|
|
I believe the problem lies in that Id is actually an alias for an underlying internal property called IdInternal so it is being excluded from the properties OData is making available for filtering despite being valid for serialization/deserialization. If this is the case then unfortunately this will not work. Since you are dealing with a "FindById" scenario can you not just expose a GetById method for this purpose?
|
|
|
I will go with GetById as a work-around. |
|