private static void UnloadGraph <T>(T obj, ActiveRecordMap activeRecordMap) where T : class, IActiveRecord, new() { foreach (BelongsToMap belongsToMap in activeRecordMap.BelongsToMappings) { IRelationship relationship = (IRelationship)belongsToMap.Field.GetValue(obj); relationship.Unload(); } foreach (HasOneMap hasOneMap in activeRecordMap.HasOneMappings) { IRelationship relationship = (IRelationship)hasOneMap.Field.GetValue(obj); relationship.Unload(); } foreach (HasManyMap hasManyMap in activeRecordMap.HasManyMappings) { IRelationship relationship = (IRelationship)hasManyMap.Field.GetValue(obj); relationship.Unload(); } foreach (HasAndBelongsToManyMap hasAndBelongsToManyMap in activeRecordMap.HasAndBelongsToManyMappings) { IRelationship relationship = (IRelationship)hasAndBelongsToManyMap.Field.GetValue(obj); relationship.Unload(); } }