本文整理汇总了C#中Command.AddParameter方法的典型用法代码示例。如果您正苦于以下问题:C# Command.AddParameter方法的具体用法?C# Command.AddParameter怎么用?C# Command.AddParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Command
的用法示例。
在下文中一共展示了Command.AddParameter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: AppendPage
public virtual void AppendPage(Command cmd, string keyFieldName, string tableName, Page page, Where where)
{
cmd.Append(" limit @0PageStartIndex, @0PageCount");
cmd.AddParameter("@0PageStartIndex", page.StartPos);
cmd.AddParameter("@0PageCount", page.Count);
}
示例3: OnValidating
/// <summary>
/// 验证处理过程,派生类重写实现具体的验证规则
/// </summary>
/// <param name="value">属性值</param>
/// <param name="source">属性所属对象</param>
/// <param name="pm">属性映射描述</param>
/// <param name="cc">数据库上下文</param>
/// <returns>bool</returns>
protected override bool OnValidating(object value, object source, Mappings.PropertyMapper pm, IConnectinContext cc)
{
if (value == null)
return true;
if (string.IsNullOrEmpty((string)value))
return true;
string sql = "select {0} from {1} where {0}[email protected]";
Command cmd = new Command(string.Format(sql, pm.ColumnName, pm.OM.Table));
cmd.AddParameter("p1", value);
object result = cc.ExecuteScalar(cmd);
return result == null || result == DBNull.Value;
}