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.
25 lines
597 B
25 lines
597 B
using System.Text;
|
|
|
|
namespace Connected.Data.Schema.Sql
|
|
{
|
|
internal class TableExists : SynchronizationQuery<bool>
|
|
{
|
|
protected override async Task<bool> OnExecute()
|
|
{
|
|
return (await Context.Select(CommandText)).Result;
|
|
}
|
|
|
|
private string CommandText
|
|
{
|
|
get
|
|
{
|
|
var text = new StringBuilder();
|
|
|
|
text.AppendLine($"IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{Unescape(Context.Schema.SchemaName())}' AND TABLE_NAME = '{Unescape(Context.Schema.Name)}')) SELECT 1 as result ELSE SELECT 0 as result");
|
|
|
|
return text.ToString();
|
|
}
|
|
}
|
|
}
|
|
}
|