/// <summary> /// Compile the query into a MobileServiceTableQueryDescription. /// </summary> /// <returns> /// The compiled OData query. /// </returns> internal MobileServiceTableQueryDescription Compile <T>(MobileServiceTableQuery <T> query) { // Compile the query from the underlying IQueryable's expression // tree MobileServiceTableQueryTranslator <T> translator = new MobileServiceTableQueryTranslator <T>(query); MobileServiceTableQueryDescription compiledQuery = translator.Translate(); return(compiledQuery); }
/// <summary> /// Translate an expression tree into a compiled query description that /// can be executed on the server. /// </summary> /// <param name="expression">The expression tree.</param> /// <returns>A compiled query description.</returns> public static MobileServiceTableQueryDescription Translate(Expression expression) { Debug.Assert(expression != null, "expression cannot be null!"); // Evaluate any independent subexpressions so we end up with a tree // full of constants or things that depend directly on our values. expression = PartialEvaulator.PartiallyEvalulate(expression); // Build a new query from the expression tree MobileServiceTableQueryTranslator translator = new MobileServiceTableQueryTranslator(); translator.Visit(expression); return translator.query; }
/// <summary> /// Translate an expression tree into a compiled query description that /// can be executed on the server. /// </summary> /// <param name="expression">The expression tree.</param> /// <returns>A compiled query description.</returns> public static MobileServiceTableQueryDescription Translate(Expression expression) { Debug.Assert(expression != null, "expression cannot be null!"); // Evaluate any independent subexpressions so we end up with a tree // full of constants or things that depend directly on our values. expression = PartialEvaulator.PartiallyEvalulate(expression); // Build a new query from the expression tree MobileServiceTableQueryTranslator translator = new MobileServiceTableQueryTranslator(); translator.Visit(expression); return(translator.query); }
/// <summary> /// Compile the query into a MobileServiceTableQueryDescription. /// </summary> /// <returns>The compiled OData query.</returns> internal MobileServiceTableQueryDescription Compile() { // Compile the query from the underlying IQueryable's expression // tree MobileServiceTableQueryDescription compiledQuery = MobileServiceTableQueryTranslator.Translate(this.Query.Expression); // Forward along the request for the total count compiledQuery.IncludeTotalCount = this.RequestTotalCount; // Associate the current table with the compiled query if (string.IsNullOrEmpty(compiledQuery.TableName)) { SerializableType type = SerializableType.Get( compiledQuery.ProjectionArgumentType ?? typeof(T)); compiledQuery.TableName = type.TableName; } return(compiledQuery); }