/// <summary> /// Optimize the database. /// </summary> /// <param name="connection">The connection.</param> /// <param name="lastdone">The last done date.</param> /// <param name="interval">Days interval to check.</param> /// <param name="force">True to force check.</param> /// <returns>The new date if done else lastdone.</returns> static public DateTime Optimize(this SQLiteConnection connection, DateTime lastdone, int interval = -1, bool force = false) { if (interval == -1) { interval = DefaultOptimizeDaysInterval; } InitializeVersion(connection); if (force || lastdone.AddDays(interval) < DateTime.Now) { connection.CheckIntegrity(); connection.Vacuum(); lastdone = DateTime.Now; } return(lastdone); }