private MemberBinding ToMemberBinding(Expression it, SelectClause selectClause) { Expression navigationProperty = Expression.MakeMemberAccess(it, _navigationProperty); if (_isCollection) { // NavigationProperty = it.NavigationProperty.Select( arg => new Item { ... } ).ToArray() // NavigationProperty = it.NavigationProperty.Select( arg => new Item { ... } ).ToList() // apply all constraints if (Select != null) { navigationProperty = Select.ApplyTo(navigationProperty); } if (Orderby != null) { navigationProperty = Orderby.ApplyTo(navigationProperty); } if (Filter != null) { navigationProperty = Filter.ApplyTo(navigationProperty); } if (Skip != null) { navigationProperty = Skip.ApplyTo(navigationProperty, ItemType); } if (Top != null) { navigationProperty = Top.ApplyTo(navigationProperty, ItemType); } // build proper select of properties var expression = BuildSelectLambdaExpression(ItemType, selectClause, NestedExpands); navigationProperty = Expression.Call(null, SelectInfo.MakeGenericMethod(ItemType, ItemType), navigationProperty, expression ); // add ToList/ToArray var loadFunction = _navigationProperty.PropertyType.IsArray ? ToArrayInfo.MakeGenericMethod(ItemType) : ToListInfo.MakeGenericMethod(ItemType); navigationProperty = Expression.Call(null, loadFunction, navigationProperty ); } else { // NavigationProperty = new Item { ... } navigationProperty = BuildMemberInit(ItemType, navigationProperty, selectClause, NestedExpands); } return(Expression.Bind(_navigationProperty, navigationProperty)); }
public IQueryable ApplyTo(IQueryable queryable, ODataQuerySettings settings) { IQueryable result = queryable; if (Filter != null) { result = Filter.ApplyTo(result, settings); } if (OrderBy != null) { result = OrderBy.ApplyTo(result, settings); } if (Top != null) { result = Top.ApplyTo(result, settings); } if (Select != null) { result = Select.ApplyTo(result, settings); } return(result); }
public IAsyncEnumerable <object> ApplyTo(IAsyncEnumerable <object> enumerable, ODataQuerySettings settings) { IAsyncEnumerable <object> result = enumerable; if (Filter != null) { result = Filter.ApplyTo(result, settings); } if (OrderBy != null) { result = OrderBy.ApplyTo(result, settings); } if (Top != null) { result = Top.ApplyTo(result, settings); } if (Select != null) { result = Select.ApplyTo <object>(result, settings); } return(result); }