public void Save(ISession session, LogMessage obj) { // populate the database using (var transaction = session.BeginTransaction()) { session.SaveOrUpdate(obj); transaction.Commit(); } }
public static void LogToDatabase(string logType, string logMessage) { LogMessageRepository rep = new LogMessageRepository(); LogMessage dbLog = new LogMessage(); dbLog.LogType = logType; dbLog.LogContent = logMessage; dbLog.LogDate = DateTime.Now; using (var session = JMMService.SessionFactory.OpenSession()) { rep.Save(session, dbLog); } logger.Info(string.Format("{0} - {1}", logType, logMessage)); }