Пример #1
0
 /// <inheritdoc />
 public IRelationType GetRelationTypeById(int id)
 {
     using (var scope = ScopeProvider.CreateScope(autoComplete: true))
     {
         return(_relationTypeRepository.Get(id));
     }
 }
Пример #2
0
        protected override IRelation PerformGet(int id)
        {
            var sql = GetBaseQuery(false);

            sql.Where(GetBaseWhereClause(), new { Id = id });

            var dto = Database.FirstOrDefault <RelationDto>(sql);

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

            var relationType = _relationTypeRepository.Get(dto.RelationType);

            if (relationType == null)
            {
                throw new Exception(string.Format("RelationType with Id: {0} doesn't exist", dto.RelationType));
            }

            var factory = new RelationFactory(relationType);
            var entity  = factory.BuildEntity(dto);

            //on initial construction we don't want to have dirty properties tracked
            // http://issues.umbraco.org/issue/U4-1946
            ((TracksChangesEntityBase)entity).ResetDirtyProperties(false);

            return(entity);
        }
Пример #3
0
        protected override Relation PerformGet(int id)
        {
            var sql = GetBaseQuery(false);

            sql.Where(GetBaseWhereClause(), new { Id = id });

            var dto = Database.FirstOrDefault <RelationDto>(sql);

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

            var relationType = _relationTypeRepository.Get(dto.RelationType);

            if (relationType == null)
            {
                throw new Exception(string.Format("RelationType with Id: {0} doesn't exist", dto.RelationType));
            }

            var factory = new RelationFactory(relationType);
            var entity  = factory.BuildEntity(dto);

            entity.ResetDirtyProperties();

            return(entity);
        }
Пример #4
0
        protected override IRelation PerformGet(int id)
        {
            var sql = GetBaseQuery(false);

            sql.Where(GetBaseWhereClause(), new { id });

            var dto = Database.Fetch <RelationDto>(SqlSyntax.SelectTop(sql, 1)).FirstOrDefault();

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

            var relationType = _relationTypeRepository.Get(dto.RelationType);

            if (relationType == null)
            {
                throw new InvalidOperationException(string.Format("RelationType with Id: {0} doesn't exist", dto.RelationType));
            }

            return(DtoToEntity(dto, relationType));
        }