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.
26 lines
613 B
26 lines
613 B
using Connected.Entities.Storage;
|
|
|
|
namespace Connected.Data.Schema.Sql;
|
|
|
|
internal class SchemaExists : SynchronizationQuery<bool>
|
|
{
|
|
public SchemaExists(string name)
|
|
{
|
|
Name = name;
|
|
}
|
|
private string Name { get; }
|
|
|
|
protected override async Task<bool> OnExecute()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(Name))
|
|
return true;
|
|
|
|
var rdr = await Context.OpenReader(new StorageOperation { CommandText = $"SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '{Name}'" });
|
|
var result = rdr.Read();
|
|
|
|
rdr.Close();
|
|
|
|
return result;
|
|
}
|
|
}
|