public void Visit(CreateIndexCommand command) { var indexCreator = _app.BusinessObjects.GetBusinessObject <UserKeysMD>(BoObjectTypes.oUserKeys); try { indexCreator.TableName = command.TableName; indexCreator.KeyName = command.IndexName; int elementLine = 0; foreach (var col in command.FieldsName) { if (elementLine > 0) { indexCreator.Elements.Add(); indexCreator.Elements.SetCurrentLine(elementLine); } indexCreator.Elements.ColumnAlias = col; elementLine++; } indexCreator.Unique = YesNo(command.IsUnique); var created = indexCreator.Add(); if (created != 0) { string error = _app.BusinessObjects.GetLastErrorDescription(); throw new B1CoreException(string.Format("Error: {0} - index: {1}", error, command.FieldsName)); } } finally { _app.BusinessObjects.ReleaseObject(indexCreator); } }
public CreateTableCommand CreateIndex(string indexName, Action <CreateIndexCommand> index) { var command = new CreateIndexCommand(Name, indexName); index(command); IndexCommands.Add(indexName, command); return(this); }
public void NeedIndex(CreateColumnCommand command) { if (command.IsIndex) { bool hasIndex = true; CreateIndexCommand indexCommand = null; if (!IndexCommands.TryGetValue(command.IndexName, out indexCommand)) { indexCommand = new CreateIndexCommand(Name, command.IndexName); hasIndex = false; } indexCommand.AddField(command.Name); if (command.IsUnique) { indexCommand.Unique(); } if (!hasIndex) { IndexCommands.Add(indexCommand.IndexName, indexCommand); } } }