public static void AddLog(string xml) { LogsContext context = new LogsContext(); SearchLog myLog = new SearchLog(); myLog.Date = DateTime.Now; myLog.QueryXml = xml.ToString(); context.SearchLogs.Add(myLog); context.SaveChanges(); }
public static void AddLog(DateTime date, string query) { Database.SetInitializer(new MigrateDatabaseToLatestVersion <LogsContext, Logs.Data.Migrations.Configuration>()); LogsContext context = new LogsContext(); using (context) { SearchLog log = new SearchLog(); log.Date = date; log.QueryXml = query; context.SearchLogs.Add(log); context.SaveChanges(); } }
//--- task 7. public static void SaveSearchLog(string queryXml, DateTime searchDate) { using (SearchLogDbContext dbContext = new SearchLogDbContext()) { SearchLog log = new SearchLog() { QueryXml = queryXml, SearchDate = searchDate, }; dbContext.SearchLogs.Add(log); dbContext.SaveChanges(); } }