Breeze Expand not working on WebAPI with EF

Posted by Rodney on Stack Overflow See other posts from Stack Overflow or by Rodney
Published on 2013-07-01T08:09:10Z Indexed on 2013/07/01 17:08 UTC
Read the original article Hit count: 279

I have published a WebAPI service which returns a list of items. I am implementing Breeze and have managed to get it basically working with filtering/sorting. However, the Expand is not working.

http://www.ftter.com/desktopmodules/framework/api/dare/dares/?$filter=DareId%20eq%2010&expand%20eq%20ToUser

You can see the ToUserId ForeignKey in the response above, but the ToUser properties are NULL (the user definitely exists)

You can see the ToUser EF navigation property in the metadata.

When I use .Include on the server side I can populate it with EF, but I don't want to do this.

    [HttpGet]
    [Queryable(AllowedQueryOptions = AllowedQueryOptions.All)]
    public HttpResponseMessage Dares()
    {
        var response = Request.CreateResponse(HttpStatusCode.OK, (IQueryable<Dare>)contextProvider.Context.Dares);
        return ControllerUtilities.GetResponseWithCorsHeader(response);
    }

and here is the generated class from my EF model (using Database First)

public partial class Dare
{
    public int DareId { get; set; }
    public int ToUserId { get; set; }
    public virtual User ToUser { get; set; }
}

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about asp.net-web-api