internal static T SetGroupRelationProxyLazyLoadDelegate <T>(this ICoreReadonlyRelationsRepository providerSession, T entity) where T : class, IRelatableEntity { if (entity == null) { return(null); } entity.RelationProxies.LazyLoadDelegate = CreateGroupRelationLazyLoadDelegate(providerSession, entity.Id); return(entity); }
/// <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; })); }
public QueryableDataSourceWrapper(IEnumerable <AbstractReadonlyEntityRepository> repositoryPool, ICoreReadonlyRelationsRepository groupRepo, Uri idRoot, IFrameworkContext context, AbstractScopedCache containerScopedCache, RepositoryContext hiveContext) { _idRoot = idRoot; _groupRepo = groupRepo; _repositoryPool = repositoryPool; FrameworkContext = context; ContainerScopedCache = containerScopedCache; HiveContext = hiveContext; }
internal static T ProcessIdsAndGroupRelationProxyDelegate <T>(ICoreReadonlyRelationsRepository groupRepo, Uri idRoot, T returnValue) where T : class, IReferenceByHiveId { if (returnValue == null) { return(null); } GroupSessionHelper.MakeIdsAbsolute(returnValue, idRoot); if (TypeFinder.IsTypeAssignableFrom <IRelatableEntity>(returnValue.GetType())) { var casted = (IRelatableEntity)returnValue; groupRepo.SetGroupRelationProxyLazyLoadDelegate(casted); } return(returnValue); }
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> >()); }
internal static IEnumerable <T> Get <T>(this IEnumerable <IReadonlyProviderRepository <T> > readonlyRepositories, ICoreReadonlyRelationsRepository groupRepo, bool allOrNothing, Uri idRoot, params HiveId[] ids) where T : class, IReferenceByHiveId { //TODO: Determine which repo is the primary one //TODO: Ensure population of the incoming queue is sorted by Ordinal var totalOutput = new HashSet <T>(); foreach (var reader in readonlyRepositories) { reader.Get <T>(allOrNothing, ids).SkipWhile(SkipAndMergeFromProviders(reader.ProviderMetadata, totalOutput)).ForEach(x => totalOutput.Add(x)); } return(totalOutput.DistinctBy(x => x.Id).Select(x => ProcessIdsAndGroupRelationProxyDelegate(groupRepo, idRoot, x))); }
public static IEnumerable <T> ExecuteMany <T>(this IEnumerable <IReadonlyEntityRepository> readonlyRepositories, ICoreReadonlyRelationsRepository groupRepo, Uri idRoot, QueryDescription query, ObjectBinder objectBinder) where T : class, IReferenceByHiveId { var totalOutput = new HashSet <T>(); foreach (var reader in readonlyRepositories) { reader.ExecuteMany <T>(query, objectBinder).SkipWhile(SkipAndMergeFromProviders(reader.ProviderMetadata, totalOutput)).ForEach(x => totalOutput.Add(x)); } return(totalOutput.DistinctBy(x => x.Id).Select(x => ProcessIdsAndGroupRelationProxyDelegate(groupRepo, idRoot, x))); }
public static IEnumerable <IRelationById> GetRelations(this ICoreReadonlyRelationsRepository session, IRelatableEntity source, Direction direction, RelationType relationType = null) { Mandate.ParameterNotNull(source, "source"); return(GetRelations(session, source.Id, direction, relationType)); }
public static IEnumerable <IRelationById> GetDescendentRelations(this ICoreReadonlyRelationsRepository session, IRelatableEntity ancestor, RelationType relationType = null) { Mandate.ParameterNotNull(ancestor, "ancestor"); return(session.GetDescendentRelations(ancestor.Id, relationType)); }
public static IEnumerable <IRelationById> GetAncestorRelations(this ICoreReadonlyRelationsRepository session, IRelatableEntity descendent, RelationType relationType = null) { Mandate.ParameterNotNull(descendent, "descendent"); return(session.GetAncestorRelations(descendent.Id, relationType)); }
public static IEnumerable <IRelationById> GetSiblingRelations(this ICoreReadonlyRelationsRepository session, HiveId siblingId, RelationType relationType = null) { Mandate.ParameterNotEmpty(siblingId, "siblingId"); return(session.GetBranchRelations(siblingId, relationType).Where(x => !x.DestinationId.EqualsIgnoringProviderId(siblingId))); }
public static IEnumerable <IRelationById> GetSiblingRelations(this ICoreReadonlyRelationsRepository session, IRelatableEntity sibling, RelationType relationType = null) { Mandate.ParameterNotNull(sibling, "sibling"); return(GetSiblingRelations(session, sibling.Id, relationType)); }
public static IEnumerable <IRelationById> GetParentRelations(this ICoreReadonlyRelationsRepository session, IRelatableEntity child, RelationType relationType = null) { Mandate.ParameterNotNull(child, "child"); return(session.GetParentRelations(child.Id, relationType)); }
public static HiveId[] GetDescendantIds(this ICoreReadonlyRelationsRepository session, HiveId sourceId, RelationType relationType) { return(session.GetDescendentRelations(sourceId, relationType).Select(x => x.DestinationId).ToArray()); }
private static HiveId[] GetAncestorRelationSourceIds(this ICoreReadonlyRelationsRepository session, RelationType relationType, HiveId sourceId) { return(session.GetAncestorRelations(sourceId, relationType).Select(x => x.SourceId).ToArray()); }
public static IEnumerable <IRelationById> GetChildRelations(this ICoreReadonlyRelationsRepository session, IRelatableEntity parent, RelationType relationType = null) { Mandate.ParameterNotNull(parent, "parent"); return(session.GetChildRelations(parent.Id, relationType)); }
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); }); }
/// <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))); }