Skip to content

emberstack/ES.FX.Sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ES.FX.Sql Build Status package

SQL Server management classes and data adapter extensions for .NET

Installation

Package Manager:

Install-Package ES.FX.Sql

.NET CLI:

dotnet add package ES.FX.Sql

Usage

Managing SQL server and databases using SQL server management object

var manager = new SqlServerManager(connectionString);

SQL Server management API

//Query if server is SQL Azure
var isAzure = manager.Server.IsAzure();

//Async - Query if server is SQL Azure
isAzure = await manager.Server.IsAzureAsync();

//Query server properties by name
var property = manager.Server.GetProperty("propertyName");

//Async - Query server properties by name
property = await manager.Server.GetPropertyAsync("propertyName");

Database management API

//Get the current database (Initial Catalog)
var database = manager.CurrentDatabase;

//Get the database by name
database = manager.Databases["databaseName"];

 //Create the database 
database.Create();

//Async - Create current database
await database.CreateAsync();

//Create the database with Azure tier details
database.Create(new AzureDatabaseTierDetails
{
    //Specify edition and service objective
    Edition = "standard",
    ServiceObjective = "S1",

    //If specified, elastic pool is used.
    ElasticPool = "PoolName"
});

//Async - Create the database with Azure tier details
await database.CreateAsync(new AzureDatabaseTierDetails
{
    //Specify edition and service objective
    Edition = "standard",
    ServiceObjective = "S1",

    //If specified, elastic pool is used.
    ElasticPool = "PoolName"
});


//Drop database
database.Drop(); 

//Async - Drop database
await database.DropAsync();


//Check if the database exists
var exists = database.Exists();

//Async - Check if the database exists
exists = await database.ExistsAsync();

Documentation

Additional documentation may be found in the Project Wiki