コード例 #1
0
 public ChangeLogDetailsAuditor(EntityEntry dbEntry, AuditLog log,
                                DbEntryValuesWrapper dbEntryValuesWrapper)
 {
     DbEntry = dbEntry;
     _log    = log;
     _dbEntryValuesWrapper = dbEntryValuesWrapper;
 }
        public void Can_Create_AuditLogDetail_ForDeletedEntity_WithoutQueryingDatabase()
        {
            var options = new DbContextOptionsBuilder <TestTrackerContext>()
                          .UseSqlServer(TestConnectionString)
                          .Options;

            NormalModel model = new NormalModel();

            using (TestTrackerContext ttc = new TestTrackerContext(options))
            {
                ttc.NormalModels.Add(model);
                ttc.SaveChanges();
                ttc.NormalModels.Remove(model);
                ttc.ChangeTracker.DetectChanges();
                var entry         = ttc.ChangeTracker.Entries().First();
                var valuesWrapper = new DbEntryValuesWrapper(entry);
                var auditor       = new ChangeLogDetailsAuditor(entry, null, valuesWrapper);

                var auditLogDetails = auditor.CreateLogDetails().ToList();
            }
        }
コード例 #3
0
        private object GetPrimaryKeyValuesOf(
            EntityEntry dbEntry,
            List <PropertyConfiguerationKey> properties)
        {
            if (properties.Count == 0)
            {
                throw new KeyNotFoundException("key not found for " + dbEntry.Entity.GetType().FullName);
            }

            var valuesWrapper = new DbEntryValuesWrapper(_dbEntry);

            if (properties.Count == 1)
            {
                return(valuesWrapper.OriginalValue(properties.First().PropertyName));
            }

            string output = "[";

            output += string.Join(",",
                                  properties.Select(colName => valuesWrapper.OriginalValue(colName.PropertyName)));

            output += "]";
            return(output);
        }
コード例 #4
0
 public SoftDeletedLogDetailsAuditor(EntityEntry dbEntry, AuditLog log, DbEntryValuesWrapper dbEntryValuesWrapper) : base(dbEntry, log, dbEntryValuesWrapper)
 {
 }
コード例 #5
0
 internal LogAuditor(EntityEntry dbEntry)
 {
     _dbEntry = dbEntry;
     _dbEntryValuesWrapper = new DbEntryValuesWrapper(_dbEntry);
 }
コード例 #6
0
 public ChangeLogDetailsAuditor(DbEntityEntry dbEntry, AuditLog log)
 {
     DbEntry = dbEntry;
     _log    = log;
     _dbEntryValuesWrapper = new DbEntryValuesWrapper(dbEntry);
 }