private void Read(IStorageObject obj, IDataReader reader) { if ((obj != null) && (reader != null)) { Type type = obj.GetType(); DbObjectInfo dbObjectInfo = DbObjectReflector.GetDbObjectInfo(type); if (dbObjectInfo == null) { throw new Exception("Cannot retrieve DbObjectInfo of type : " + type.ToString()); } foreach (KeyValuePair <string, DynamicPropertyInfo> pair in dbObjectInfo.DynamicPropertyInfos) { string key = pair.Key; DynamicPropertyInfo info2 = pair.Value; try { ConvertUtils.SetValueToObject(reader[info2.DataFieldName], obj, key, info2.PropertyType); } catch (Exception exception) { throw new ConvertValueException(info2.DataFieldName, exception); } } } }
private DbObjectInfo GetDbObjectInfo(Type type) { DbObjectInfo dbObjectInfo = DbObjectReflector.GetDbObjectInfo(type); if (dbObjectInfo == null) { throw new Exception("Cannot retrieve DbObjectInfo of type : " + type.ToString()); } return(dbObjectInfo); }
internal static bool Compare(IStorageObject obj1, IStorageObject obj2) { if (!obj1.GetType().Equals(obj2.GetType())) { return(false); } DbObjectInfo dbObjectInfo = DbObjectReflector.GetDbObjectInfo(obj1.GetType()); foreach (KeyValuePair <string, DynamicPropertyInfo> pair in dbObjectInfo.DynamicPropertyInfos) { object obj3 = obj1.GetValue(pair.Value.PropertyName); object obj4 = obj2.GetValue(pair.Value.PropertyName); if (obj3 != obj4) { return(false); } } return(true); }
public bool RetrieveByKey(IStorageObject obj, object keyValue) { DynamicPropertyInfo pkDynamicPropertyInfo = DbObjectTools.GetPkDynamicPropertyInfo(DbObjectReflector.GetDbObjectInfo(obj.GetType()), true); if (pkDynamicPropertyInfo == null) { throw new ArgumentException("Primary Key Not Found"); } return(this.Retrieve(obj, pkDynamicPropertyInfo.DataFieldName, keyValue)); }