本文整理汇总了C#中Command.AppendFormat方法的典型用法代码示例。如果您正苦于以下问题:C# Command.AppendFormat方法的具体用法?C# Command.AppendFormat怎么用?C# Command.AppendFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Command
的用法示例。
在下文中一共展示了Command.AppendFormat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendOrders
public static void AppendOrders(Command cmd, IEnumerable<Order> orders, IDbAdapter adapter)
{
if (orders != null)
if (orders.Count() > 0)
{
cmd.Append(" order by ");
foreach (Order oo in orders)
cmd.AppendFormat("{0},", oo.ToString(adapter));
cmd.RemoveLastChar();
}
}
示例2: AppendWhereByEnsuredKey
public static void AppendWhereByEnsuredKey(Command cmd, Where where, string keyFieldName, IDbAdapter adapter)
{
if (where == null)
return;
switch (where.Type)
{
case WhereType.Key:
cmd.AppendFormat(" where {0}[email protected]", keyFieldName);
cmd.AddParameter("@0WhereKey", where.SingleObject);
break;
case WhereType.Custom:
if (!string.IsNullOrEmpty(where.QueryString))
{
cmd.AppendFormat(" where {0}", where.QueryString);
for (int i = 0; i < where.Parameters.Count; i++)
cmd.AddParameter("@" + i, where.Parameters[i]);
}
break;
}
AppendOrders(cmd, where.Orders, adapter);
}
示例3: AppendSelect
public static void AppendSelect(Command cmd, Select select, IDbAdapter adapter)
{
if (select == null)
{
cmd.Append(" *");
return;
}
switch (select.Type)
{
case SelectType.All:
default:
cmd.Append(" *");
break;
case SelectType.Custom:
if (select.Fields.Count == 0)
return;
cmd.Append(" ");
foreach (string s in select.Fields)
cmd.AppendFormat("{0},", adapter.EnsureIdentifier(s));
cmd.RemoveLastChar();
break;
}
}