コード例 #1
0
 /// <summary>
 /// Generates the text for a Placeholder builder.
 /// </summary>
 /// <param name="item">The Placeholder builder to generate the text for.</param>
 protected internal override void VisitPlaceholder(Placeholder item)
 {
     writer.Write(item.Value);
 }
コード例 #2
0
        public void TestSelect_AddFilter()
        {
            const string commandText = "SELECT * FROM Customer";
            CommandBuilder commandBuilder = new CommandBuilder();
            SelectBuilder select = (SelectBuilder)commandBuilder.GetCommand(commandText);
            Column customerId = select.Sources["Customer"].Column("CustomerId");
            customerId.Qualify = false;
            Placeholder parameter = new Placeholder("@customerId");
            select.AddWhere(new EqualToFilter(customerId, parameter));

            Formatter formatter = new Formatter();
            string actual = formatter.GetCommandText(select);
            string expected = "SELECT * FROM Customer WHERE CustomerId = @customerId";
            Assert.AreEqual(expected, actual, "The SELECT statement was not updated as expected.");
        }
コード例 #3
0
 private object buildNamedItem(MatchResult result)
 {
     List<string> parts = new List<string>();
     buildMultipartIdentifier(result, parts);
     if (parts.Count > 1)
     {
         // if is a period-separated, multiple-part identifier, it is a column
         Namespace qualifier = getNamespace(parts.Take(parts.Count - 2));
         string tableName = parts[parts.Count - 2];
         AliasedSource source = scope.GetSource(tableName);
         string columnName = parts[parts.Count - 1];
         return source.Column(columnName);
     }
     string name = parts[0];
     if (options.PlaceholderPrefix != null && name.StartsWith(options.PlaceholderPrefix))
     {
         // if the identifier begins with the placeholder prefix, treat is as a placeholder
         Placeholder placeholder = new Placeholder(name);
         return placeholder;
     }
     AliasedSource singleSource;
     if (scope.HasSingleSource(out singleSource))
     {
         // there is only one source in the query, so assume a column
         Column column = singleSource.Column(name);
         column.Qualify = false;
         return column;
     }
     // otherwise, we have no idea what the name represents
     // in order for the SQL to roundtrip without alteration, just use a placeholder
     Placeholder unknown = new Placeholder(name);
     return unknown;
 }
コード例 #4
0
 /// <summary>
 /// Visits a Placeholder builder.
 /// </summary>
 /// <param name="item">The item to visit.</param>
 protected internal virtual void VisitPlaceholder(Placeholder item)
 {
 }
コード例 #5
0
 /// <summary>
 /// Visits a Placeholder builder.
 /// </summary>
 /// <param name="item">The item to visit.</param>
 protected internal virtual void VisitPlaceholder(Placeholder item)
 {
 }