/// <summary> /// Retrieves all objects of type U and their retrospective keys whence given the key for type T /// </summary> /// <typeparam name="T">The type of the sorce object</typeparam> /// <typeparam name="U">The type of the related object</typeparam> /// <param name="store">The underlying store</param> /// <param name="keyT">The key of the source object</param> /// <param name="transformer"></param> /// <returns></returns> public static IEnumerable <KeyValuePair <string, U> > GetRelatedFor <T, U>(this IKVStore store, Key keyT, ITypeStringTransformer transformer = null) { var tr = transformer ?? new ForeignKeyTypeStringTransformer(); var keys = store.GetRelatedKeysFor <T, U>(keyT); return(keys.Select(key => new KeyValuePair <string, U>(key, store.Get <U>(key)))); }
/// <summary> /// Clears all relationships in both directtions between two types of objects connected to the source key. /// </summary> /// <typeparam name="T">The type of the sorce object</typeparam> /// <typeparam name="U">The type of the related object</typeparam> /// <param name="store">The underlying store</param> /// <param name="keyT">The key of the source object</param> /// <param name="transformer"></param> public static void ClearRelationships <T, U>(this IKVStore store, Key keyT, ITypeStringTransformer transformer = null) { var tr = transformer ?? new ForeignKeyTypeStringTransformer(); var keys = store.GetRelatedKeysFor <T, U>(keyT, tr); foreach (var keyU in keys) { store.RemoveRelationship <T, U>(keyT, keyU, tr); } }