locked
web api + OData - $filter not created by client RRS feed

Answers

All replies

  • User1066278571 posted

    Hi

    Use the OData v4 client generator instead

    https://damienbod.wordpress.com/2014/07/09/web-api-odata-v4-using-an-odata-t4-generated-client-part-8/

    Greetings Damien

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 8, 2015 4:45 AM
  • User1784888476 posted

    Thanks, but I am using it already, because only OData v4 client is available as VS2013 extension.

    I tried with Simple.OData.Client also,

    var query = client
        .For<ElectronicPrograms>()
        .Filter(x => x.Id == 2)
        .FindEntriesAsync();
     
    var test = query.Result.ToList();//all records returned

    but result is the same (all records returned).

    Thursday, January 8, 2015 5:08 AM
  • User1784888476 posted

    Resolved. I was using old (from tutorial) OData v4 Endpoint config.

    Instead:

    using System.Web.OData.Builder;
    using System.Web.OData.Extensions;
    and
    ODataModelBuilder builder = new ODataConventionModelBuilder();
    builder.EntitySet<Product>("Products");
    config.MapODataServiceRoute(
    routeName: "ODataRoute",
    routePrefix: null,
    model: builder.GetEdmModel());

    should be used:

    using System.Web.Http.OData.Builder;
    using System.Web.Http.OData.Extensions;
    and
    config.Routes.MapODataServiceRoute("odata", "odata", builder.GetEdmModel());

    Friday, January 9, 2015 5:48 AM