You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Framework/Connected.Data/Schema/Sql/IdentityInsert.cs

35 lines
647 B

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();
}
}
}
}