Example #1
0
        /// <summary>
        /// Returns descendent relations
        /// </summary>
        /// <param name="repo">The repository to recusively select child relations from</param>
        /// <param name="ancestorId"></param>
        /// <param name="relationType"></param>
        /// <returns></returns>
        public IEnumerable <IRelationById> PerformGetDescendentRelations(ICoreReadonlyRelationsRepository repo, HiveId ancestorId, RelationType relationType = null)
        {
            var childRelations = repo.GetChildRelations(ancestorId, relationType).ToArray();

            return(childRelations.SelectRecursive(x =>
            {
                var childRelationsSub = repo.GetChildRelations(x.DestinationId, relationType).ToArray();
                return childRelationsSub;
            }));
        }
Example #2
0
        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);
            });
        }
Example #3
0
        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> >());
        }
Example #4
0
 public static IEnumerable <IRelationById> GetChildRelations(this ICoreReadonlyRelationsRepository session, IRelatableEntity parent, RelationType relationType = null)
 {
     Mandate.ParameterNotNull(parent, "parent");
     return(session.GetChildRelations(parent.Id, relationType));
 }