PropertyEntryExtensions.cs 674 B

123456789101112131415161718192021222324252627
  1. using Microsoft.EntityFrameworkCore;
  2. using Microsoft.EntityFrameworkCore.ChangeTracking;
  3. namespace VberZero.EntityHistory.Extensions;
  4. internal static class PropertyEntryExtensions
  5. {
  6. internal static object GetNewValue(this PropertyEntry propertyEntry)
  7. {
  8. if (propertyEntry.EntityEntry.State == EntityState.Deleted)
  9. {
  10. return null;
  11. }
  12. return propertyEntry.CurrentValue;
  13. }
  14. internal static object GetOriginalValue(this PropertyEntry propertyEntry)
  15. {
  16. if (propertyEntry.EntityEntry.State == EntityState.Added)
  17. {
  18. return null;
  19. }
  20. return propertyEntry.OriginalValue;
  21. }
  22. }