|
@@ -2,9 +2,11 @@
|
|
|
using System.Collections.Concurrent;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
+using System.Data;
|
|
|
using System.Linq;
|
|
|
using System.Linq.Expressions;
|
|
|
using System.Reflection;
|
|
|
+using System.Runtime.CompilerServices;
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
|
//using PropertyChanged;
|
|
@@ -57,6 +59,8 @@ namespace InABox.Core
|
|
|
{
|
|
|
CheckOriginalValues();
|
|
|
|
|
|
+ LoadedColumns = new HashSet<string>();
|
|
|
+
|
|
|
UserProperties = new UserProperties();
|
|
|
//UserProperties.ParentType = this.GetType();
|
|
|
UserProperties.OnPropertyChanged += (o, n, b, a) =>
|
|
@@ -115,6 +119,10 @@ namespace InABox.Core
|
|
|
[DoNotPersist]
|
|
|
public ConcurrentDictionary<string, object?> OriginalValues { get; set; }
|
|
|
|
|
|
+ [DoNotPersist]
|
|
|
+ [DoNotSerialize]
|
|
|
+ public HashSet<string> LoadedColumns { get; set; }
|
|
|
+
|
|
|
protected virtual void SetChanged(string name, object? before, object? after)
|
|
|
{
|
|
|
bChanged = true;
|
|
@@ -183,6 +191,8 @@ namespace InABox.Core
|
|
|
if (name.Equals("OriginalValues"))
|
|
|
return;
|
|
|
|
|
|
+ LoadedColumns.Add(name);
|
|
|
+
|
|
|
if (!HasChanged(before, after))
|
|
|
return;
|
|
|
|
|
@@ -366,6 +376,17 @@ namespace InABox.Core
|
|
|
|
|
|
public static class BaseObjectExtensions
|
|
|
{
|
|
|
+ public static bool HasColumn<T>(this T sender, string column)
|
|
|
+ where T : BaseObject
|
|
|
+ {
|
|
|
+ return sender.LoadedColumns.Contains(column);
|
|
|
+ }
|
|
|
+ public static bool HasColumn<T, TType>(this T sender, Expression<Func<T, TType>> column)
|
|
|
+ where T : BaseObject
|
|
|
+ {
|
|
|
+ return sender.LoadedColumns.Contains(CoreUtils.GetFullPropertyName(column, "."));
|
|
|
+ }
|
|
|
+
|
|
|
public static bool HasOriginalValue<T>(this T sender, string propertyname) where T : BaseObject
|
|
|
{
|
|
|
return sender.OriginalValues != null && sender.OriginalValues.ContainsKey(propertyname);
|