private object GetChangedValues(DoBase aDoBase, ref bool HasChangedRecord) { HasChangedRecord = false; ExpandoObject expando = new ExpandoObject(); if (aDoBase.OldValues != null && aDoBase.OldValues.Count > 0) { foreach (var old in aDoBase.OldValues) { if (aDoBase.GetType().GetProperty(old.Key).GetValue(aDoBase) != old.Value && !(aDoBase.GetType().GetProperty(old.Key).GetCustomAttributesData().Where(x => x.AttributeType.Name == "IgnoreAttribute").Any())) { HasChangedRecord = true; expando.AddProperty(old.Key, aDoBase.GetType().GetProperty(old.Key).GetValue(aDoBase)); } } } return(expando); }
internal static void SetPrimaryValue(this DoBase aDoBase, object Id) { PropertyInfo[] propertyInfos = aDoBase.GetType().GetProperties(); foreach (PropertyInfo property in propertyInfos) { if (property.GetCustomAttributesData().Where(x => x.AttributeType.Name == "KeyAttribute").Any()) { property.SetValue(aDoBase, Id); } } }
public static long GetPrimaryKeyValue(this DoBase aDoBase) { PropertyInfo[] propertyInfos = aDoBase.GetType().GetProperties(); foreach (PropertyInfo property in propertyInfos) { if (property.GetCustomAttributesData().Where(x => x.AttributeType.Name == "KeyAttribute").Any()) { return(Convert.ToInt64(property.GetValue(aDoBase))); } } return(0); }
public static string GetPrimaryKey(this DoBase aDoBase) { PropertyInfo[] propertyInfos = aDoBase.GetType().GetProperties(); foreach (PropertyInfo property in propertyInfos) { if (property.GetCustomAttributesData().Where(x => x.AttributeType.Name == "KeyAttribute").Any()) { return(property.Name); } } return(null); }
private Dictionary <string, object> ConstructOldValues(DoBase aDoBase) { Dictionary <string, object> OldValues = new Dictionary <string, object>(); PropertyInfo[] propertyInfos = aDoBase.GetType().GetProperties(); foreach (PropertyInfo property in propertyInfos) { if (!property.GetCustomAttributesData().Where(x => x.AttributeType.Name == "IgnoreAttribute").Any()) { OldValues.Add(property.Name, property.GetValue(aDoBase)); } } return(OldValues); }
public static string GetTableName(this DoBase aDoBase) { return(aDoBase.GetType().Name); }