Update: Repository Monitor
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Data.Objects;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -9,6 +11,13 @@ namespace Disco.Data.Repository.Monitor
|
||||
{
|
||||
public class RepositoryMonitorEvent
|
||||
{
|
||||
[JsonIgnore]
|
||||
internal ObjectStateEntry objectEntryState { get; set; }
|
||||
[JsonIgnore]
|
||||
internal DbEntityEntry dbEntityState { get; set; }
|
||||
[JsonIgnore]
|
||||
internal bool afterCommit { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public DiscoDataContext dbContext { get; set; }
|
||||
|
||||
@@ -31,5 +40,17 @@ namespace Disco.Data.Repository.Monitor
|
||||
public object[] EntityKey { get; set; }
|
||||
|
||||
public string[] ModifiedProperties { get; set; }
|
||||
|
||||
public T GetPreviousPropertyValue<T>(string PropertyName)
|
||||
{
|
||||
if (afterCommit)
|
||||
throw new InvalidOperationException("Unable to determine property values after repository commit");
|
||||
else
|
||||
return (T)dbEntityState.OriginalValues[PropertyName];
|
||||
}
|
||||
public T GetCurrentPropertyValue<T>(string PropertyName)
|
||||
{
|
||||
return (T)dbEntityState.CurrentValues[PropertyName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user