using System.Text; namespace Connected.Data.Schema.Sql { internal class IdentityInsert : TableTransaction { public IdentityInsert(string tableName, bool on) { On = on; TableName = tableName; } private string TableName { get; } private bool On { get; } protected override async Task OnExecute() { await Context.Execute(CommandText); } private string CommandText { get { var text = new StringBuilder(); var switchCommand = On ? "ON" : "OFF"; text.AppendLine($"SET IDENTITY_INSERT {Escape(Context.Schema.SchemaName(), TableName)} {switchCommand}"); return text.ToString(); } } } }