/// <summary> /// Returns a new ObjectQueryState instance with the specified navigation property path specified as an Include span. /// For eLINQ queries the Include operation is modelled as a method call expression applied to the source ObectQuery, /// so the <see cref="Span"/> property is always <c>null</c> on the returned instance. /// </summary> /// <typeparam name="TElementType">The element type of the resulting query</typeparam> /// <param name="sourceQuery">The ObjectQuery on which Include was called; required to build the new method call expression</param> /// <param name="includePath">The new Include path</param> /// <returns>A new ObjectQueryState instance that incorporates the Include path, in this case a new method call expression</returns> internal override ObjectQueryState Include <TElementType>(ObjectQuery <TElementType> sourceQuery, string includePath) { MethodInfo includeMethod = sourceQuery.GetType().GetMethod("Include", BindingFlags.Public | BindingFlags.Instance); Debug.Assert(includeMethod != null, "Unable to find ObjectQuery.Include method?"); Expression includeCall = Expression.Call(Expression.Constant(sourceQuery), includeMethod, new Expression[] { Expression.Constant(includePath, typeof(string)) }); ObjectQueryState retState = new ELinqQueryState(this.ElementType, this.ObjectContext, includeCall); this.ApplySettingsTo(retState); return(retState); }
/// <summary> /// Provides an untyped method capable of creating a strong-typed ObjectQuery /// (based on the <paramref name="ofType"/> argument) and returning it as an /// instance of the untyped (in a generic sense) ObjectQuery base class. /// </summary> /// <param name="expression">The LINQ expression that defines the new query</param> /// <param name="ofType">The result type of the new ObjectQuery</param> /// <returns>A new ObjectQuery<ofType>, as an instance of ObjectQuery</returns> private ObjectQuery CreateQuery(Expression expression, Type ofType) { ObjectQueryState queryState; if (_query == null) { queryState = new ELinqQueryState(ofType, _context, expression); } else { queryState = new ELinqQueryState(ofType, _query, expression); } return(queryState.CreateQuery()); }
/// <summary> /// Creates a new query from an expression. /// </summary> /// <typeparam name="S">The element type of the query.</typeparam> /// <param name="expression">Expression forming the query.</param> /// <returns>A new ObjectQuery<S> instance.</returns> private ObjectQuery <S> CreateQuery <S>(Expression expression) { ObjectQueryState queryState; if (_query == null) { queryState = new ELinqQueryState(typeof(S), _context, expression); } else { queryState = new ELinqQueryState(typeof(S), _query, expression); } return(new ObjectQuery <S>(queryState)); }