locked
How can I force $expand in a service operation RRS feed

  • Question

  • Is there any way to force a $expand within a service operation regardless of whether it is specified on the client? For example, if I have a model with Authors and his/her related Books, is there a way to write a service operation which would return all the info from the Author table for a specified author as wall as populate the Author entity's Books collection. I would like to control this behavior entirely from the server side without specifying $expand on the client side.

    Thanks,

    Rob
    Monday, February 16, 2009 8:08 PM

Answers

  • Hi Rob,
     What is the underlying provider for you data service ?
     If its Entity Framework , you can use the Include API to expand the relations before you send a response  from the Service Operation ,

    ex :
    public IQueryable<Author> GetAuthors(){
    return this.CurrentDataSource.Authors.Include("Books");

    Phani Raj Astoria
    Wednesday, February 18, 2009 9:45 PM
    Moderator

All replies

  • Hi Rob,
     What is the underlying provider for you data service ?
     If its Entity Framework , you can use the Include API to expand the relations before you send a response  from the Service Operation ,

    ex :
    public IQueryable<Author> GetAuthors(){
    return this.CurrentDataSource.Authors.Include("Books");

    Phani Raj Astoria
    Wednesday, February 18, 2009 9:45 PM
    Moderator
  • If using EF then why not just use _join_ ? or other relevant EF syntax ?
    Thursday, December 16, 2010 3:01 PM