internal static SqlQuerySpec TranslateQuery(Expression inputExpression)
        {
            inputExpression = ConstantEvaluator.PartialEval(inputExpression);
            SqlQuery query = ExpressionToSql.TranslateQuery(inputExpression);

            return(new SqlQuerySpec(query.ToString()));
        }
        /// <summary>
        /// This function exists for testing only.
        /// </summary>
        /// <param name="inputExpression">Expression to translate.</param>
        /// <returns>A string describing the expression translation.</returns>
        internal static string TranslateExpression(Expression inputExpression)
        {
            TranslationContext context = new TranslationContext();

            inputExpression = ConstantEvaluator.PartialEval(inputExpression);
            SqlScalarExpression scalarExpression = ExpressionToSql.VisitNonSubqueryScalarExpression(inputExpression, context);

            return(scalarExpression.ToString());
        }
        internal static SqlQuerySpec TranslateQuery(
            Expression inputExpression,
            CosmosSerializationOptions serializationOptions = null)
        {
            inputExpression = ConstantEvaluator.PartialEval(inputExpression);
            SqlQuery query = ExpressionToSql.TranslateQuery(inputExpression, serializationOptions);

            return(new SqlQuerySpec(query.ToString()));
        }
Пример #4
0
        internal static SqlQuerySpec TranslateQuery(Expression inputExpression)
        {
            inputExpression = ConstantEvaluator.PartialEval(inputExpression);
            SqlQuery      query   = ExpressionToSql.TranslateQuery(inputExpression);
            StringBuilder builder = new StringBuilder();

            query.AppendToBuilder(builder);
            return(new SqlQuerySpec(builder.ToString()));
        }
Пример #5
0
        /// <summary>
        /// This function exists for testing only.
        /// </summary>
        /// <param name="inputExpression">Expression to translate.</param>
        /// <returns>A string describing the expression translation.</returns>
        internal static string TranslateExpression(Expression inputExpression)
        {
            TranslationContext context = new TranslationContext();

            inputExpression = ConstantEvaluator.PartialEval(inputExpression);
            SqlScalarExpression scalarExpression = ExpressionToSql.VisitScalarExpression(inputExpression, context);
            StringBuilder       builder          = new StringBuilder();

            scalarExpression.AppendToBuilder(builder);
            return(builder.ToString());
        }
Пример #6
0
        internal static SqlQuerySpec TranslateQuery(
            Expression inputExpression,
            CosmosLinqSerializerOptions linqSerializerOptions,
            IDictionary <object, string> parameters)
        {
            inputExpression = ConstantEvaluator.PartialEval(inputExpression);
            SqlQuery query     = ExpressionToSql.TranslateQuery(inputExpression, parameters, linqSerializerOptions);
            string   queryText = null;
            SqlParameterCollection sqlParameters = new SqlParameterCollection();

            if (parameters != null && parameters.Count > 0)
            {
                foreach (KeyValuePair <object, string> keyValuePair in parameters)
                {
                    sqlParameters.Add(new Microsoft.Azure.Cosmos.Query.Core.SqlParameter(keyValuePair.Value, keyValuePair.Key));
                }
            }
            queryText = query.ToString();

            SqlQuerySpec sqlQuerySpec = new SqlQuerySpec(queryText, sqlParameters);

            return(sqlQuerySpec);
        }