static void Main(string[] args) { IFactory operateFactory = new DogDoFactory(); DoBase dogDo = operateFactory.CreateDo(); dogDo.Do(); Console.Read(); }
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 DoBase Open() { SqlResult sqlResult = BlQuery.GetOpenQuery(idoBase); idoBase = DataAccess.QueryFirstOrDefault(sqlResult); if (idoBase != null) { idoBase.State = ObjState.Selected; idoBase.InfoMsg = new InfoMessage { Message = "Data selected & Opened Successfully." }; } return(idoBase); }
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); }
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); }
public static string GetTableName(this DoBase aDoBase) { return(aDoBase.GetType().Name); }
internal static SqlResult GetOpenQuery(DoBase aDoBase) { return(QueryAdapter.GetSql(aDoBase.GetTableName()).Where(aDoBase.GetPrimaryKey(), aDoBase.GetPrimaryKeyValue()).Compile()); }
internal static SqlResult GetUpdateQuery(DoBase aDoBase, object ChangedValues) { return(QueryAdapter.GetSql(aDoBase.GetTableName()).AsUpdate(ChangedValues).Compile()); }
internal static SqlResult GetInsertQuery(DoBase aDoBase) { return(QueryAdapter.GetSql(aDoBase.GetTableName()).AsInsert(aDoBase, returnId: true).Compile()); }