public static void ModifyTableDefinitionAddOptionField( TableDefinition tableDefinition, string optFieldName, SqlDbType sqlType, bool addFieldIndex ) { tableDefinition.AddField( new FieldDefinition( optFieldName, sqlType, false, false ) ); if (addFieldIndex) { tableDefinition.Indexes.Add( new IndexDefinition( tableDefinition, optFieldName + "_indx", false, optFieldName ) ); } }
internal TableDefinition GetTableDefinition() { TableDefinition tableDefinition = new TableDefinition(TableName); foreach (NormalizeFieldInfo field in Fields) { tableDefinition.AddField(new FieldDefinition(field.Name, field.Type, field.IsUnique, field.IsNotNull)); } foreach (NormalizeInfo childDirectory in ChildDirectories) { tableDefinition.AddField(new FieldDefinition(childDirectory.GetAsFk(), SqlDbType.BigInt, true, false)); } if (!string.IsNullOrEmpty(this._tableIndexFields)) { string[] tableIndexFieldsList = this._tableIndexFields.Split(',') .Select(x => x.Trim()) .Where(x => !string.IsNullOrWhiteSpace(x)) .ToArray(); tableDefinition.Indexes.Add( new IndexDefinition( tableDefinition, "idx_" + this.TableName + "_config_fields", false, tableIndexFieldsList ) ); } return tableDefinition; }