public int Update(Model m) { Type t = m.GetType(); PropertyInfo[] pis = t.GetProperties(); StringBuilder sb = new StringBuilder(); SqlParameter[] sp = new SqlParameter[pis.Length]; sb.Append("UPDATE [dbName].[dbo].[tableName] SET "); int index = 0; foreach (PropertyInfo item in pis) { if (index == 0) sb.Append(string.Format("{0}=@{0}", item.Name)); else sb.Append(string.Format(",{0}=@{0}", item.Name)); sp[index] = new SqlParameter("@" + item.Name, item.GetValue(m, null)); index++; } sb.Append(" WHERE id=@id"); int i = ExecuteNonQuery.....; return i; }