/// <summary> /// Logs the specified Log Entry. /// </summary> /// <param name="logEntry">The Log Entry to write to the Log.</param> protected override void WriteLogEntry(LogEntry logEntry) { using (SqliteDataContext context = new SqliteDataContext(Settings.FilePath)) { context.LogEvents.Add(logEntry); context.SaveChanges(); } }
/// <summary> /// Loads the content of the Log from Sqlite. /// </summary> /// <param name="xmlReader">The XmlReader instance containing the data.</param> public void LoadSqlite(string filePath) { if (filePath.IsNullOrBlank()) throw new ArgumentNullException("filePath"); if (!File.Exists(filePath)) throw new FileNotFoundException(String.Format("Specified File '{0}' not found.", filePath), filePath); using (SqliteDataContext context = new SqliteDataContext(filePath)) { LogEvents logEvents = new LogEvents(context.LogEvents); Entries.AddRange(logEvents.Select(logEvent => (LogEntry) logEvent)); } }