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