c# - How to return a field from another entity in Odata V4 -


i working on odata v4 project , wish return field table in result set.

so have 2 tables

account: id, name, address, colorcode,

product: id, accountid

accountid foreign key mapped id field in account table

i have following partial class

    public partial class product      {            public string colorcode {             { return account.colorcode; }         }  public datetimeoffset? edmcreated         {                         {                 return created ;             }         }      } 

and controller:

 [enablequery(pagesize = 200)]     public iqueryable<product > get()     {         return _db. product.asqueryable();     } 

this returns data product data entity cant seem colorcode field in result set.

how can achieve above

please refer answer other question: how join 2 entities in odata model builder

and in addition, don't need write specific $expand , $select in request url mentioned in answer. enablequery attribute in productscontroller handles correctly.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -