예제 #1
0
 public static void Initialize()
 {
     using (var context = new ElmahContext())
     {
         context.Database.Initialize(true);
     }
 }
예제 #2
0
 public ActionResult Index()
 {
     var daysToKeep = ConfigurationManager.AppSettings["DaysToKeepRecords"];
     int days = 0 - Convert.ToInt32(daysToKeep);
     using (var db = new ElmahContext())
     {
         var sql = $"DELETE FROM [ErrorLogEntries] WHERE ReceivedAt < DATEADD(d, {days}, getdate())";
         int result = db.Database.ExecuteSqlCommand(sql);
         var message = $"Deleted old error records: {result}";
         TempData["notifySuccess"] = message;
         return Content(message);
     }
 }