I use ODATA controller method overload

public IQueryable<TD> Get(ODataQueryOptions<OrdersViewsDto> options) 

the settings for the OrdersViewsDto type come to me

then I get all the entities of type OrdersViews

 var emp = db.OrdersViews.AsQueryable(); 

and when I try to apply the options passed in the request

  if (options.Top != null) { emp = options.Top.ApplyTo(emp , new ODataQuerySettings()); } 

as a result, I get an error

 Не удается использовать выражение типа "System.Data.Entity.Core.Objects.ObjectQuery`1[Data.Entities.OrdersViews]" для параметра типа "System.Linq.IQueryable`1[Data.Dto.OrdersViewsDto]" метода "System.Linq.IQueryable`1[Data.Dto.OrdersViewsDto] Take[OrdersViewsDto](System.Linq.IQueryable`1[Data.Dto.OrdersViewsDto], Int32)" 

As far as I understand it because of the database I get entities of the type OrdersViews and try to apply the settings for the type OrdersViewsDto. This is actually the question of what actions I need to apply in order to avoid this error and, for example, to obtain an object of type ODataQueryOptions from an object of type ODataQueryOptions

    1 answer 1

    In the end, I did this, but if there are fewer fields in the OrdersViews or there is a discrepancy with OrdersViewsDto

     var TEContext = new ODataQueryContext(options.Context.Model, typeof(OrdersViews), options.Context.Path); var TEOption = new ODataQueryOptions<OrdersViews>(TEContext, options.Request);