c# - .NET ODataController class to return collection of type strutcurally unrelated to type for controller -


i have class, myclasscontroller inherits odatacontroller. i've been able use "automagic" routing access properties of scaler collections types using, e.g., /path/to/myclass(100)/someproperty. need return collection of class that's structurally unrelated myclass (i.e., there no references connecting 2 classes) logically, there's relationship between two. i'd able getting /path/to/myclass(100)/relatedthings/. how can set up? i'm setting myclass , related classes using odataconventionmodelbuilder.entityset<> in application_start.

i'm using microsoft.odata.core 6.13.0 (odata 4.0).

edit: left out details question didn't realize relevant of design decisions i'd made elsewhere in application, accepted answer best solves problem without taking details account. ended making bound odata function in myclass controller returned related things. found if didn't include namespace or trailing slash, http requested yielded error. is, /path/to/myclass(100)/default.relatingthings/ works. i'm looking ways removing need trailing slash , namespace. (edit: call config.enableunqualifiednamecall(true) when setting odata routing; see https://stackoverflow.com/a/35156885/1102726.)

your odata routes not have match relationships in storage schema; i.e., lack of structural relationship irrelevant. add property myclass similar following:

public icollection<thing> relatedthings { get; set; } 

then define action method property:

public iqueryable<thing> getrelatedthings([fromodatauri] int key) {     // fill-in data access logic. } 

you won't request /path/to/myclass(100)?$expand=relatedthings, able request /path/to/myclass(100)/relatedthings desire.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -