/// <summary> /// 执行存储过程不带参数 /// </summary> /// <param name="db">链接数据库EF DbContext对象</param> /// <param name="cmdText">SQL语句、存储过程名称</param> /// <returns></returns> public static int ExecuteNonQueryPro(this CTMSContext db, string cmdText) { try { return(db.ExecuteNonQuery(CommandType.StoredProcedure, cmdText, null)); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// 执行SQL语句带参数 /// </summary> /// <param name="db">链接数据库EF DbContext对象</param> /// <param name="cmdText">SQL语句、存储过程名称</param> /// <param name="sqlParams">参数 SqlParameter集合</param> /// <returns></returns> public static int ExecuteNonQuery(this CTMSContext db, string cmdText, DbParameter[] sqlParams) { try { return(db.ExecuteNonQuery(CommandType.Text, cmdText, sqlParams)); } catch (Exception ex) { throw new Exception(ex.Message); } }