示例#1
0
        /// <summary>
        /// Perform parameter substitutions and return the resulting AML
        /// </summary>
        /// <param name="context">Localization context (e.g. from
        /// <see cref="ElementFactory.LocalizationContext"/>)</param>
        /// <returns>AML string</returns>
        public string ToNormalizedAml(IServerContext context)
        {
            var aml = this.Aml;

            if (_sub.ParamCount > 0 || aml.IndexOf(ParameterSubstitution.DateRangeAttribute) > 0)
            {
                return(_sub.Substitute(aml, context));
            }
            return(aml);
        }
示例#2
0
        /// <summary>
        /// Formats an AML string by substituting the @0 style parameters with the
        /// arguments specified.
        /// </summary>
        /// <param name="format">Query to format</param>
        /// <param name="args">Arguments to substitute into the query</param>
        public string FormatAml(string format, params object[] args)
        {
            var sub = new ParameterSubstitution();

            sub.AddIndexedParameters(args);
            return(sub.Substitute(format, LocalizationContext));
        }
示例#3
0
        /// <summary>Append the specified command with parameters the SQL. @# (e.g. @0) style
        /// parameters are replaced</summary>
        /// <remarks>Depending on the number of commands written and the <see cref="Threshold"/>, the
        /// buffer of SQL commands might be sent to the server after this call. See
        /// <see cref="Innovator.Client.Command"/> and <see cref="ParameterSubstitution"/> for more
        /// information on how parameters are substituted</remarks>
        public SqlBatchWriter Command(string format, params object[] args)
        {
            _subs.AddIndexedParameters(args);
            var value = _subs.Substitute(format, _aml.LocalizationContext);

            if (_conn == null)
            {
                _builder.AppendLine(value);
            }
            else
            {
                _builder.AppendEscapedXml(value).AppendLine();
                ProcessCommand(false);
            }
            _subs.ClearParameters();
            return(this);
        }
示例#4
0
 /// <summary>
 /// Return a result from an AML string by substituting the @0 style parameters
 /// with the arguments specified.
 /// </summary>
 /// <param name="xml">Query to format</param>
 /// <param name="args">Arguments to substitute into the query</param>
 public IResult FromXml(string xml, params object[] args)
 {
     using (var writer = new ResultWriter(this, null, null, false))
     {
         var sub = new ParameterSubstitution();
         sub.AddIndexedParameters(args);
         sub.Substitute(xml, LocalizationContext, writer);
         return(writer.Result);
     }
 }
    public override IEnumerable<string> GetParameterNames(string query)
    {
      var paramNames = new List<string>();
      var subs = new ParameterSubstitution()
      {
        ParameterAccessListener = (n) => paramNames.Add(n)
      };
      subs.Substitute(query, _conn.AmlContext.LocalizationContext);

      return paramNames.Distinct().OrderBy(n => n);
    }