示例#1
0
 /// <inheritdoc />
 public IEnumerable <IRelation> GetPagedByRelationTypeId(int relationTypeId, long pageIndex, int pageSize, out long totalRecords, Ordering ordering = null)
 {
     using (var scope = ScopeProvider.CreateScope(autoComplete: true))
     {
         var query = Query <IRelation>().Where(x => x.RelationTypeId == relationTypeId);
         return(_relationRepository.GetPagedRelationsByQuery(query, pageIndex, pageSize, out totalRecords, ordering));
     }
 }
示例#2
0
        /// <inheritdoc />
        public IEnumerable <IEntitySlim> GetPagedDescendants(UmbracoObjectTypes objectType, long pageIndex, int pageSize, out long totalRecords,
                                                             IQuery <IUmbracoEntity> filter = null, Ordering ordering = null, bool includeTrashed = true)
        {
            using (ScopeProvider.CreateScope(autoComplete: true))
            {
                var query = Query <IUmbracoEntity>();
                if (includeTrashed == false)
                {
                    query.Where(x => x.Trashed == false);
                }

                return(_entityRepository.GetPagedResultsByQuery(query, objectType.GetGuid(), pageIndex, pageSize, out totalRecords, filter, ordering));
            }
        }
示例#3
0
        /// <inheritdoc />
        public IEnumerable <IEntitySlim> GetPagedDescendants(int id, UmbracoObjectTypes objectType, long pageIndex, int pageSize, out long totalRecords,
                                                             IQuery <IUmbracoEntity> filter = null, Ordering ordering = null)
        {
            using (ScopeProvider.CreateScope(autoComplete: true))
            {
                var objectTypeGuid = objectType.GetGuid();
                var query          = Query <IUmbracoEntity>();

                if (id != Cms.Core.Constants.System.Root)
                {
                    // lookup the path so we can use it in the prefix query below
                    var paths = _entityRepository.GetAllPaths(objectTypeGuid, id).ToArray();
                    if (paths.Length == 0)
                    {
                        totalRecords = 0;
                        return(Enumerable.Empty <IEntitySlim>());
                    }
                    var path = paths[0].Path;
                    query.Where(x => x.Path.SqlStartsWith(path + ",", TextColumnType.NVarchar));
                }

                return(_entityRepository.GetPagedResultsByQuery(query, objectTypeGuid, pageIndex, pageSize, out totalRecords, filter, ordering));
            }
        }
示例#4
0
        /// <inheritdoc />
        public IEnumerable <IEntitySlim> GetPagedDescendants(IEnumerable <int> ids, UmbracoObjectTypes objectType, long pageIndex, int pageSize, out long totalRecords,
                                                             IQuery <IUmbracoEntity> filter = null, Ordering ordering = null)
        {
            totalRecords = 0;

            var idsA = ids.ToArray();

            if (idsA.Length == 0)
            {
                return(Enumerable.Empty <IEntitySlim>());
            }

            using (ScopeProvider.CreateScope(autoComplete: true))
            {
                var objectTypeGuid = objectType.GetGuid();
                var query          = Query <IUmbracoEntity>();

                if (idsA.All(x => x != Cms.Core.Constants.System.Root))
                {
                    var paths = _entityRepository.GetAllPaths(objectTypeGuid, idsA).ToArray();
                    if (paths.Length == 0)
                    {
                        totalRecords = 0;
                        return(Enumerable.Empty <IEntitySlim>());
                    }
                    var clauses = new List <Expression <Func <IUmbracoEntity, bool> > >();
                    foreach (var id in idsA)
                    {
                        // if the id is root then don't add any clauses
                        if (id == Cms.Core.Constants.System.Root)
                        {
                            continue;
                        }

                        var entityPath = paths.FirstOrDefault(x => x.Id == id);
                        if (entityPath == null)
                        {
                            continue;
                        }

                        var path = entityPath.Path;
                        var qid  = id;
                        clauses.Add(x => x.Path.SqlStartsWith(path + ",", TextColumnType.NVarchar) || x.Path.SqlEndsWith("," + qid, TextColumnType.NVarchar));
                    }
                    query.WhereAny(clauses);
                }

                return(_entityRepository.GetPagedResultsByQuery(query, objectTypeGuid, pageIndex, pageSize, out totalRecords, filter, ordering));
            }
        }
示例#5
0
        /// <inheritdoc />
        public IEnumerable <IEntitySlim> GetPagedChildren(int id, UmbracoObjectTypes objectType, long pageIndex, int pageSize, out long totalRecords,
                                                          IQuery <IUmbracoEntity> filter = null, Ordering ordering = null)
        {
            using (ScopeProvider.CreateScope(autoComplete: true))
            {
                var query = Query <IUmbracoEntity>().Where(x => x.ParentId == id && x.Trashed == false);

                return(_entityRepository.GetPagedResultsByQuery(query, objectType.GetGuid(), pageIndex, pageSize, out totalRecords, filter, ordering));
            }
        }