public void WriteLog(string userName, string moduleName, string tableName, string eventType, object newValues) { using (IDbContextBase context = DbContextFactory.GetDbContext()) { context.CloseLog(); AuditLog audiLog = new AuditLog(); audiLog.Id = Guid.NewGuid(); audiLog.UserName = userName; audiLog.ModuleName = moduleName; audiLog.TableName = tableName; audiLog.EventType = eventType; audiLog.NewValues = JsonConvert.SerializeObject(newValues, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); audiLog.Time = DateTime.Now; context.Insert(audiLog); } }