public static Func <HiveId, RelationProxyBucket> CreateGroupRelationLazyLoadDelegate(ICoreReadonlyRelationsRepository providerSession, HiveId id) { var idCopy = id; return(x => { var parents = providerSession.GetParentRelations(idCopy).Select(y => new RelationById(y.SourceId, y.DestinationId, y.Type, y.Ordinal, y.MetaData.ToArray())); var children = providerSession.GetChildRelations(idCopy).Select(y => new RelationById(y.SourceId, y.DestinationId, y.Type, y.Ordinal, y.MetaData.ToArray())); return new RelationProxyBucket(parents, children); }); }
public static IEnumerable <IRelationById> GetRelations(this ICoreReadonlyRelationsRepository session, HiveId sourceId, Direction direction, RelationType relationType = null) { switch (direction) { case Direction.Ancestors: return(session.GetAncestorRelations(sourceId, relationType)); case Direction.Children: return(session.GetChildRelations(sourceId, relationType)); case Direction.Descendents: return(session.GetDescendentRelations(sourceId, relationType)); case Direction.Parents: return(session.GetParentRelations(sourceId, relationType)); } return(Enumerable.Empty <IReadonlyRelation <IRelatableEntity, IRelatableEntity> >()); }
public static IEnumerable <IRelationById> GetParentRelations(this ICoreReadonlyRelationsRepository session, IRelatableEntity child, RelationType relationType = null) { Mandate.ParameterNotNull(child, "child"); return(session.GetParentRelations(child.Id, relationType)); }
/// <summary> /// Returns ancestor relations /// </summary> /// <param name="repo">The repository to recursively select parent relations from</param> /// <param name="descendentId"></param> /// <param name="relationType"></param> /// <returns></returns> public IEnumerable <IRelationById> PerformGetAncestorRelations(ICoreReadonlyRelationsRepository repo, HiveId descendentId, RelationType relationType = null) { return(repo.GetParentRelations(descendentId, relationType).SelectRecursive(x => repo.GetParentRelations(x.SourceId, relationType))); }