Esempio n. 1
0
        public void LogChanges(DbContext context)
        {
            var changes = _changesFinder.GetChanges(context);

            _context.ChangeLogs.AddRange(changes);
            _context.SaveChanges();
        }
        public void LogChanges(DbContext context)
        {
            var changes = _changesFinder.GetChanges(context);

            Console.WriteLine($"  Id | Username        | ChangeTime          | Typename             | PropertyName    | Old  | New");
            foreach (var c in changes)
            {
                Console.WriteLine($"{c.Id,4} | {c.User,15} | {c.ChangeTime.ToString("yyyy.mm.dd hh:mm:ss")} | {c.TypeName,20} | {c.PropertyName,15} | {c.OldValue,4} | {c.NewValue}");
            }
        }
Esempio n. 3
0
        public void Complete()
        {
            if (!_context.ChangeTracker.HasChanges())
            {
                return;
            }
            var changes = _changesFinder?.GetChanges(_context).ToList();

            _context.SaveChanges();
            _changesLogger?.LogChanges(changes);
        }