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