public override void SaveAuditedEntity(AuditedEntity auditedEntity) { var audit = new AuditRecord { Action = (byte)auditedEntity.Action, AuditDate = DateTime.Now, ParentTable = auditedEntity.ParentEntityType.Name, ParentKey = auditedEntity.ParentKey, Table = auditedEntity.EntityType.Name, TableKey = auditedEntity.EntityKey, UserName = "******", }; foreach (var modifiedProperty in auditedEntity.ModifiedProperties) { audit.AuditRecordProperties.Add( new AuditRecordProperty { PropertyName = modifiedProperty.DisplayName, OldValue = modifiedProperty.OldValue, NewValue = modifiedProperty.NewValue }); } if (audit.AuditRecordProperties.Count > 0) { AuditRecords.AddObject(audit); } }
/// <summary> /// Create a new AuditRecord object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="action">Initial value of the Action property.</param> /// <param name="auditDate">Initial value of the AuditDate property.</param> /// <param name="parentKey">Initial value of the ParentKey property.</param> /// <param name="tableKey">Initial value of the TableKey property.</param> public static AuditRecord CreateAuditRecord(global::System.Int32 id, global::System.Byte action, global::System.DateTime auditDate, global::System.Int32 parentKey, global::System.Int32 tableKey) { AuditRecord auditRecord = new AuditRecord(); auditRecord.Id = id; auditRecord.Action = action; auditRecord.AuditDate = auditDate; auditRecord.ParentKey = parentKey; auditRecord.TableKey = tableKey; return(auditRecord); }
/// <summary> /// Deprecated Method for adding a new object to the AuditRecords EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToAuditRecords(AuditRecord auditRecord) { base.AddObject("AuditRecords", auditRecord); }