using Azure.Cosmos;
using System;
using System.Collections.Generic;
using System.Text;

namespace TEAMModelOS.SDK.DI.AzureCosmos.Inner
{
    public   class AzureCosmosQuery
    {
        public string QueryText { get; set; }

        public Dictionary<string, object> Parameters { get; set; }

        public QueryDefinition CosmosQueryDefinition
        {
            get
            {
                QueryDefinition queryDefinition = new QueryDefinition(QueryText);

                if (Parameters != null)
                {
                    foreach (var parameter in Parameters)
                    {
                        queryDefinition = queryDefinition.WithParameter(parameter.Key, parameter.Value);
                    }
                }

                return queryDefinition;
            }
        }

        public AzureCosmosQuery() { }

        public AzureCosmosQuery(string queryText)
        {
            QueryText = queryText;
        }

        public AzureCosmosQuery(string queryText, Dictionary<string, object> parameters)
        {
            QueryText = queryText;
            Parameters = parameters;
        }
    }
}
