Implementing OData with WebApi and Mapped Models

后端 未结 2 1563
一个人的身影
一个人的身影 2021-01-02 07:09

I am trying to implement OData in WebApi. I am using the repository pattern and EF5 (in the backend) which is still consistent with all the examples I have found. Here is

2条回答
  •  無奈伤痛
    2021-01-02 08:09

    If the Queryable you return is via a dbContext.dbSet.Select(x => new Model { Id = x.Id}) mechanism instead of AutoMapper. Then applying conditions on the Queryable can be translated and evaluated by the EF LINQ provider automatically. Otherwise, you're going to have to write a custom LINQ provider which changes the expressions from being expressions based off of Model properties to expressions off of EF_Class properties.

提交回复
热议问题