Пример #1
0
        protected override IEnumerable <IMigrationEntry> PerformGetAll(params int[] ids)
        {
            var factory = new MigrationEntryFactory();

            if (ids.Any())
            {
                return(Database.Fetch <MigrationDto>("WHERE id in (@ids)", new { ids = ids })
                       .Select(x => factory.BuildEntity(x)));
            }

            return(Database.Fetch <MigrationDto>("WHERE id > 0")
                   .Select(x => factory.BuildEntity(x)));
        }
Пример #2
0
        protected override IEnumerable <IMigrationEntry> PerformGetByQuery(IQuery <IMigrationEntry> query)
        {
            var factory    = new MigrationEntryFactory();
            var sqlClause  = GetBaseQuery(false);
            var translator = new SqlTranslator <IMigrationEntry>(sqlClause, query);
            var sql        = translator.Translate();

            return(Database.Fetch <MigrationDto>(sql).Select(x => factory.BuildEntity(x)));
        }
Пример #3
0
        public IMigrationEntry FindEntry(string migrationName, SemVersion version)
        {
            var versionString = version.ToString();

            var sql = new Sql().Select("*")
                      .From <MigrationDto>(SqlSyntax)
                      .Where <MigrationDto>(x => x.Name.InvariantEquals(migrationName) && x.Version == versionString);

            var result = Database.FirstOrDefault <MigrationDto>(sql);

            var factory = new MigrationEntryFactory();

            return(result == null ? null : factory.BuildEntity(result));
        }
Пример #4
0
        protected override IMigrationEntry PerformGet(int id)
        {
            var sql = GetBaseQuery(false);

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

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

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

            var factory = new MigrationEntryFactory();
            var entity  = factory.BuildEntity(dto);

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

            return(entity);
        }