//Invoked by methodname(string), don't change method name private void SaveAssociationCollection(PropertyInfo propertyInfo) { Type fieldType = propertyInfo.PropertyType; if (!fieldType.IsGenericType) { return; } IDPCollection collection = (IDPCollection)propertyInfo.GetValue(this, null); collection.Save(); }
public virtual bool Delete() { RowObjectAdapter d = new RowObjectAdapter(this); d.Apply(); //check 1..many table dependency foreach (PropertyInfo propertyInfo in this.columnProperties) { AssociationAttribute association = Reflex.GetAssociationAttribute(propertyInfo); if (association == null) { continue; } if (!propertyInfo.PropertyType.IsGenericType) { continue; } IDPCollection collection = (IDPCollection)propertyInfo.GetValue(this, null); if (collection.Count == 0) { continue; } Type[] typeParameters = propertyInfo.PropertyType.GetGenericArguments(); if (typeParameters.Length == 1 && typeParameters[0].IsSubclassOf(typeof(PersistentObject))) { throw new ApplicationException(string.Format( "Error: data persistent object on Table {0} cannot be deleted because Table {1} depends on it.", TableName, collection.TableName)); } } d.RowChanged += RowChanged; return(d.Delete()); }
public void FillIdentity() { if (association == null) { return; } if (!IsColumn1Identity()) { return; } if (mappingType == MappingType.One2Many) { object value1 = propertyInfo1.GetValue(dpoInstance, null); IDPCollection collection = (IDPCollection)propertyInfo2.GetValue(this, null); foreach (DataRow row in collection.Table.Rows) { row[association.Column2] = value1; IDPObject dpo = (IDPObject)collection.GetObject(row); dpo.FillIdentity(row); } } }