public HiloSequence(IConnectionFactory factory, string entityName, HiloSettings settings) { _factory = factory; _entityName = entityName; CurrentHi = -1; CurrentLo = 1; MaxLo = settings.MaxLo; Increment = settings.Increment; }
public HiloSequence(ICommandRunner runner, string entityName, HiloSettings settings) { _runner = runner; _entityName = entityName; CurrentHi = -1; CurrentLo = 1; MaxLo = settings.MaxLo; Increment = settings.Increment; }
public ISequence Hilo(Type documentType, HiloSettings settings) { // TODO -- here, need to see if the mt_hilo table is created, and if not, // do it through _creation. if (!_schema.SchemaTableNames().Contains("mt_hilo")) { _creation.RunScript("mt_hilo"); } return(new HiloSequence(_factory, documentType.Name, settings)); }
public void can_replace_hilo_def_settings() { var mapping = DocumentMapping.For<LongId>(); var newDef = new HiloSettings {Increment = 3, MaxLo = 33}; mapping.HiloSettings(newDef); var sequence = mapping.IdStrategy.ShouldBeOfType<HiloIdGeneration>(); sequence.MaxLo.ShouldBe(newDef.MaxLo); sequence.Increment.ShouldBe(newDef.Increment); }
public ISequence Hilo(Type documentType, HiloSettings settings) { // TODO -- here, need to see if the mt_hilo table is created, and if not, // do it through _creation. if (!_schema.SchemaTableNames().Contains("mt_hilo")) { _creation.RunScript("mt_hilo"); } return new HiloSequence(_runner, documentType.Name, settings); }
public void default_everything() { var defaults = new HiloSettings(); var store = DocumentStore.For("something"); var mapping = store.Schema.MappingFor(typeof (IntDoc)); var idStrategy = mapping.IdStrategy.ShouldBeOfType<HiloIdGeneration>(); idStrategy.Increment.ShouldBe(defaults.Increment); idStrategy.MaxLo.ShouldBe(defaults.MaxLo); }
public ISequence Hilo(Type documentType, HiloSettings settings) { if (!_schema.DbObjects.TableExists(Table)) { if (_options.AutoCreateSchemaObjects == AutoCreate.None) { throw new InvalidOperationException($"Hilo table is missing, but {nameof(StoreOptions.AutoCreateSchemaObjects)} is {_options.AutoCreateSchemaObjects}"); } var sqlScript = SchemaBuilder.GetSqlScript(Table.Schema, "mt_hilo"); _logger.SchemaChange(sqlScript); _factory.RunSql(sqlScript); } return new HiloSequence(_factory, _options, documentType.Name, settings); }
public HiloIdGeneration(Type documentType, HiloSettings hiloSettings) : base("sequence", typeof(ISequence)) { _hiloSettings = hiloSettings; DocumentType = documentType; }
public IdentityKeyGeneration(IDocumentMapping mapping, HiloSettings hiloSettings) : base("sequence", typeof(ISequence)) { _mapping = mapping; _hiloSettings = hiloSettings; }