Beispiel #1
0
        public virtual IEnumerable <IUmbracoEntity> GetAll(Guid objectTypeId, params int[] ids)
        {
            if (ids.Any())
            {
                foreach (var id in ids)
                {
                    yield return(Get(id, objectTypeId));
                }
            }
            else
            {
                bool isContent = objectTypeId == new Guid(Constants.ObjectTypes.Document);
                bool isMedia   = objectTypeId == new Guid(Constants.ObjectTypes.Media);
                var  sql       = GetBaseWhere(GetBase, isContent, isMedia, string.Empty, objectTypeId).Append(GetGroupBy(isContent, isMedia));
                var  dtos      = isMedia
                               ? _work.Database.Fetch <UmbracoEntityDto, UmbracoPropertyDto, UmbracoEntityDto>(
                    new UmbracoEntityRelator().Map, sql)
                               : _work.Database.Fetch <UmbracoEntityDto>(sql);
                var factory = new UmbracoEntityFactory();

                foreach (var dto in dtos)
                {
                    var entity = factory.BuildEntity(dto);
                    yield return(entity);
                }
            }
        }
        public virtual IUmbracoEntity Get(int id)
        {
            var sql = GetBaseWhere(GetBase, false, false, id);
            var nodeDto = _work.Database.FirstOrDefault<UmbracoEntityDto>(sql);
            if (nodeDto == null)
                return null;

            var factory = new UmbracoEntityFactory();
            var entity = factory.BuildEntity(nodeDto);

            return entity;
        }
        public virtual IUmbracoEntity Get(int id, Guid objectTypeId)
        {
            bool isContent = objectTypeId == new Guid(Constants.ObjectTypes.Document);
            bool isMedia = objectTypeId == new Guid(Constants.ObjectTypes.Media);
            var sql = GetBaseWhere(GetBase, isContent, isMedia, objectTypeId, id).Append(GetGroupBy(isContent, isMedia));
            var nodeDto = _work.Database.FirstOrDefault<UmbracoEntityDto>(sql);
            if (nodeDto == null)
                return null;

            var factory = new UmbracoEntityFactory();
            var entity = factory.BuildEntity(nodeDto);

            return entity;
        }
Beispiel #4
0
        public virtual IUmbracoEntity Get(int id)
        {
            var sql     = GetBaseWhere(GetBase, false, false, id);
            var nodeDto = _work.Database.FirstOrDefault <UmbracoEntityDto>(sql);

            if (nodeDto == null)
            {
                return(null);
            }

            var factory = new UmbracoEntityFactory();
            var entity  = factory.BuildEntity(nodeDto);

            return(entity);
        }
Beispiel #5
0
        public virtual IUmbracoEntity Get(int id, Guid objectTypeId)
        {
            bool isContent = objectTypeId == new Guid(Constants.ObjectTypes.Document);
            bool isMedia   = objectTypeId == new Guid(Constants.ObjectTypes.Media);
            var  sql       = GetBaseWhere(GetBase, isContent, isMedia, objectTypeId, id).Append(GetGroupBy(isContent, isMedia));
            var  nodeDto   = _work.Database.FirstOrDefault <UmbracoEntityDto>(sql);

            if (nodeDto == null)
            {
                return(null);
            }

            var factory = new UmbracoEntityFactory();
            var entity  = factory.BuildEntity(nodeDto);

            return(entity);
        }
        public virtual IEnumerable<IUmbracoEntity> GetAll(Guid objectTypeId, params int[] ids)
        {
            if (ids.Any())
            {
                foreach (var id in ids)
                {
                    yield return Get(id, objectTypeId);
                }
            }
            else
            {
                bool isContent = objectTypeId == new Guid(Constants.ObjectTypes.Document);
                bool isMedia = objectTypeId == new Guid(Constants.ObjectTypes.Media);
                var sql = GetBaseWhere(GetBase, isContent, isMedia, string.Empty, objectTypeId).Append(GetGroupBy(isContent, isMedia));
                var dtos = isMedia
                               ? _work.Database.Fetch<UmbracoEntityDto, UmbracoPropertyDto, UmbracoEntityDto>(
                                   new UmbracoEntityRelator().Map, sql)
                               : _work.Database.Fetch<UmbracoEntityDto>(sql);
                var factory = new UmbracoEntityFactory();

                foreach (var dto in dtos)
                {
                    var entity = factory.BuildEntity(dto);
                    yield return entity;
                }
            }
        }