/// <summary>
 /// Sets a N1QL statement to be executed.
 /// </summary>
 /// <param name="statement">Any valid N1QL statement for a POST request, or a read-only N1QL statement (SELECT, EXPLAIN) for a GET request.</param>
 /// <returns>
 /// A reference to the current <see cref="QueryOptions" /> for method chaining.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">statement</exception>
 /// <remarks>
 /// Will erase a previous optimization of a statement using Prepared.
 /// </remarks>
 public IQueryOptions Statement(string statement)
 {
     if (string.IsNullOrWhiteSpace(statement))
     {
         throw new ArgumentNullException(nameof(statement));
     }
     _statement       = statement;
     _preparedPayload = null;
     _prepareEncoded  = false;
     return(this);
 }
 /// <summary>
 ///  Sets a N1QL statement to be executed in an optimized way using the given queryPlan.
 /// </summary>
 /// <param name="preparedPlan">The <see cref="QueryPlan"/> that was prepared beforehand.</param>
 /// <param name="originalStatement">The original statement (eg. SELECT * FROM default) that the user attempted to optimize</param>
 /// <returns>A reference to the current <see cref="QueryOptions"/> for method chaining.</returns>
 /// <remarks>Required if statement not provided, will erase a previously set Statement.</remarks>
 /// <exception cref="ArgumentNullException"><paramref name="preparedPlan"/> is <see langword="null" />.</exception>
 public IQueryOptions Prepared(QueryPlan preparedPlan, string originalStatement)
 {
     if (preparedPlan == null || string.IsNullOrWhiteSpace(preparedPlan.EncodedPlan))
     {
         throw new ArgumentNullException(nameof(preparedPlan));
     }
     if (string.IsNullOrWhiteSpace(originalStatement))
     {
         throw new ArgumentNullException(nameof(originalStatement));
     }
     _statement       = originalStatement;
     _preparedPayload = preparedPlan;
     _prepareEncoded  = true;
     return(this);
 }
 /// <summary>
 /// Creates a query using the given plan as an optimization for the originalStatement.
 /// </summary>
 /// <param name="plan">The plan.</param>
 /// <param name="originalStatement">The original statement, unoptimized.</param>
 /// <returns></returns>
 public static IQueryOptions Create(QueryPlan plan, string originalStatement)
 {
     return(new QueryOptions(plan, originalStatement));
 }
 public QueryOptions(QueryPlan plan, string originalStatement) : this()
 {
     _statement       = originalStatement;
     _preparedPayload = plan;
     _prepareEncoded  = true;
 }
 public QueryOptions(string statement) : this()
 {
     _statement       = statement;
     _preparedPayload = null;
     _prepareEncoded  = false;
 }
 internal QueryOptions WithQueryPlan(QueryPlan queryPlan)
 {
     _preparedPayload = queryPlan;
     return(this);
 }