@@ -173,28 +173,70 @@ public static ODataQuery<T> TopSkip<T>(this ODataQuery<T> query, string topText
173173 return query ;
174174 }
175175
176+ public static IQueryable < T > ApplyQueryOptionsWithoutSelectExpand < T > (
177+ this ODataQuery < T > query ,
178+ IODataQueryOptions rawQueryOptions ,
179+ string entitySetName = null )
180+ {
181+ return ApplyQueryOptionsInternal ( query , rawQueryOptions , entitySetName ) ;
182+ }
183+
184+ public static IEnumerable < ISelectExpandWrapper > ApplyQueryOptions < T > (
185+ this ODataQuery < T > query ,
186+ IODataQueryOptions rawQueryOptions ,
187+ string entitySetName = null )
188+ {
189+ return ApplyQueryOptionsInternal ( query , rawQueryOptions , entitySetName ) . SelectExpand (
190+ rawQueryOptions . Select ,
191+ rawQueryOptions . Expand ,
192+ entitySetName ) ;
193+ }
194+
195+ private static ODataQuery < T > ApplyQueryOptionsInternal < T > ( ODataQuery < T > query , IODataQueryOptions rawQueryOptions , string entitySetName )
196+ {
197+ if ( query == null ) throw new ArgumentNullException ( nameof ( query ) ) ;
198+ if ( rawQueryOptions == null ) throw new ArgumentNullException ( nameof ( rawQueryOptions ) ) ;
199+
200+ if ( rawQueryOptions . Filters != null )
201+ {
202+ foreach ( string filter in rawQueryOptions . Filters )
203+ {
204+ query = query . Filter ( filter , entitySetName ) ;
205+ }
206+ }
207+
208+ if ( rawQueryOptions . OrderBy != null )
209+ {
210+ query = query . OrderBy ( rawQueryOptions . OrderBy , entitySetName ) ;
211+ }
212+
213+ query = query . TopSkip ( rawQueryOptions . Top , rawQueryOptions . Skip ) ;
214+
215+ return query ;
216+ }
217+
176218 /// <summary>
177- /// The Filter.
178- /// </summary>
179- /// <param name="query">
180- /// The OData aware query.
181- /// </param>
182- /// <param name="filterText">
183- /// The $filter parameter text.
184- /// </param>
185- /// <param name="entitySetName">
186- /// The entity set name.
187- /// </param>
188- /// <typeparam name="T">
189- /// The query type param
190- /// </typeparam>
191- /// <returns>
192- /// The <see cref="ODataQuery{T}"/> query with applied filter parameter.
193- /// </returns>
194- /// <exception cref="ArgumentNullException">
195- /// Argument Null Exception
196- /// </exception>
197- public static ODataQuery < T > Filter < T > ( this ODataQuery < T > query , string filterText , string entitySetName = null )
219+ /// The Filter.
220+ /// </summary>
221+ /// <param name="query">
222+ /// The OData aware query.
223+ /// </param>
224+ /// <param name="filterText">
225+ /// The $filter parameter text.
226+ /// </param>
227+ /// <param name="entitySetName">
228+ /// The entity set name.
229+ /// </param>
230+ /// <typeparam name="T">
231+ /// The query type param
232+ /// </typeparam>
233+ /// <returns>
234+ /// The <see cref="ODataQuery{T}"/> query with applied filter parameter.
235+ /// </returns>
236+ /// <exception cref="ArgumentNullException">
237+ /// Argument Null Exception
238+ /// </exception>
239+ public static ODataQuery < T > Filter < T > ( this ODataQuery < T > query , string filterText , string entitySetName = null )
198240 {
199241 if ( query == null ) throw new ArgumentNullException ( nameof ( query ) ) ;
200242 if ( filterText == null ) throw new ArgumentNullException ( nameof ( filterText ) ) ;
0 commit comments