Web API Queryable - how to apply AutoMapper?

前端 未结 4 1154
一整个雨季
一整个雨季 2020-11-30 23:03

I\'ve got a simple WebApi method like this decorated with the OData queryable attribute.

    [Queryable]
    public virtual IQueryable Get()         


        
4条回答
  •  长情又很酷
    2020-11-30 23:52

    I have couple of observations/comments on the proposed solution 1. If Person is used in the query context and PersonDTO is returned then whole concept of MVVM goes away. I guess it becomes tightly coupled. I would rather just use Person all the way or if you are not looking to return child records then in my opinion Automapper has an Extension "Project", try using that. 2. With this approach the $inlinepagecount query option will not function as intended because it will get the count of PersonDTO instead of Person. (Well one way to get around that problem would be to use PageResult and set the properties yourself.) Regards.

提交回复
热议问题