您可以基于(可能)可变数量的参数“动态”构建参数化查询,并对其进行迭代以将其传递。
因此,类似:
List foo; // assuming you have a List of items, in reality, it may be a List<int> or a List<myObject> with an id property, etc.StringBuilder query = new StringBuilder( "UPDATE TABLE_1 SET STATUS = ? WHERe ID IN ( ?")for( int i = 1; i++; i < foo.Count ){ // Bit naive query.Append( ", ?" );}query.Append( " );" );MySqlCommand m = new MySqlCommand(query.ToString());for( int i = 1; i++; i < foo.Count ){ m.Parameters.Add(new MySqlParameter(...));}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)