Exemplo n.º 1
0
 public IEnumerable <T> ExecuteByProcTable <T>(string procName, DbParameter[] dbParameter)
 {
     if (dbTransaction == null)
     {
         using (var dbConnection = Connection)
         {
             DynamicParameters dp = DatabaseCommon.GetDynamicParameter(dbParameter);
             return(dbConnection.Query <T>(procName, dp, commandType: CommandType.StoredProcedure));
         }
     }
     else
     {
         dbTransaction.Connection.Execute(procName, dbParameter, dbTransaction);
         return(null);
     }
 }
Exemplo n.º 2
0
 public int ExecuteByProc(string procName, params DbParameter[] dbParameter)
 {
     if (dbTransaction == null)
     {
         using (var connection = Connection)
         {
             DynamicParameters dp = DatabaseCommon.GetDynamicParameter(dbParameter);
             return(connection.Execute(procName, dp, null, null, CommandType.StoredProcedure));
         }
     }
     else
     {
         dbTransaction.Connection.Execute(procName, dbParameter, dbTransaction);
         return(0);
     }
 }
Exemplo n.º 3
0
 public DataTable ExecuteByProcReportTable(string procName, DbParameter[] dbParameter)
 {
     if (dbTransaction == null)
     {
         using (var dbConnection = Connection)
         {
             DynamicParameters dp = DatabaseCommon.GetDynamicParameter(dbParameter);
             var IDataReader      = new DbHelper(dbConnection).ExecuteReader(CommandType.StoredProcedure, procName, dbParameter);
             return(ConvertExtension.IDataReaderToDataTable(IDataReader));
         }
     }
     else
     {
         dbTransaction.Connection.Execute(procName, dbParameter, dbTransaction);
         return(null);
     }
 }
Exemplo n.º 4
0
 public int ExecuteByProcReturn(string procName, DbParameter[] dbParameter)
 {
     if (dbTransaction == null)
     {
         using (var connection = Connection)
         {
             DynamicParameters dp = DatabaseCommon.GetDynamicParameter(dbParameter);
             dp.Add("@RES", string.Empty, DbType.String, ParameterDirection.ReturnValue);
             connection.Execute(procName, dp, null, null, CommandType.StoredProcedure);
             return(dp.Get <int>("@RES"));
         }
     }
     else
     {
         dbTransaction.Connection.Execute(procName, dbParameter, dbTransaction);
         return(0);
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// 实体插入dapper作实现
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="entity"></param>
 /// <returns></returns>
 public int Insert <T>(T entity, string NotUpdateColName = "") where T : class
 {
     return(ExecuteBySql(DatabaseCommon.InsertSql <T>(entity, NotUpdateColName).ToString(), DatabaseCommon.GetDynamicParameter <T>(entity)));
 }