Aiv*_*ler 9 .net c# enterprise-library dbcommand input-parameters
如何将DbCommand参数复制到另一个DbCommand,我想要一个DbCommand与我的上一个参数相同的新参数DbCommand.但现在使用不同的sql字符串.
您可以将需要重用的代码放在单独的方法中:
public DbCommand RecycledParameters(string sql, IList<DbParameter> parameters)
{
var result = db.GetSqlStringCommand(sql);
foreach(DbParameter p in parameters)
{
db.AddInParameter(result, p.ParameterName, p.DbType, p.Value);
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7754 次 |
| 最近记录: |