예제 #1
0
 public static int Commit()
 {
     try
     {
         return(EFContextFactory.GetCurrentDbContext().SaveChanges());
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
예제 #2
0
 public int ExcuteSql(string strSql, DbParameter[] parameters)
 {
     try
     {
         var dbContext = EFContextFactory.GetCurrentDbContext();
         return(parameters == null?dbContext.Database.ExecuteSqlCommand(strSql)
                    : EFContextFactory.GetCurrentDbContext().Database.ExecuteSqlCommand(strSql, parameters));
     }
     catch (Exception ex)
     {
         throw new Exception("执行SQL语句时发生异常:" + ex.Message);
     }
 }