xpf.Script.SQLServer.Config

Adds the required configuration entry to the existing App.Config or Web.Config or creates one if none exists.


Keywords
xpf.Script, Scripting, BDD, integration, TDD, testing, config, SQLServer, SQL, dynamic
License
MS-PL
Install
Install-Package xpf.Script.SQLServer.Config -Version 0.1.0

Documentation

xpf.Script

Is a cross platform scripting abstraction for scripting engines such as SQL Server, PowerShell, Razor or Http. With SQL Server being the only currently supported scripting engine. Demand for additional engines can be added with community support.

The following code demonstrates how you can execute a simple SQL Script using the library:

 var result = new Script()
     .Database() // Specifies to use the SQL Server Scripting engine
     .UsingCommand("SELECT @RowCount = COUNT(*) FROM Customer WHERE Name = @Name")
     .WithIn(new {Name = "John"})
     .WithOut(new { RowCount = DbType.Int32})
     .Execute();

The library takes care of defining input and output parameters and provides a more natural way to define them. The library supports the ability to use embedded resource files as script input and have them reference other resource files allowing for easy reuse of scripts.

Scripts.VerifyCustomerRecord.sql

  IF(EXISTS(SELECT 1 FROM Customer WHERE CustomerId = @CustomerId))
    RAISE ERROR (1,23,'Customer Already exists')

Scripts.AddCustomerRecord.sql

  :r Scripts.VerifyCustomerRecord.sql

  INSERT INTO Customer(@CustomerId, CustomerName, Address)
        VALUES(@CustomerId, @CustomerName, @Address)

Execute scripts

 var result = new Script()
     .Database() // Specifies to use the SQL Server Scripting engine
     .UsingNestedScript("Scripts.AddCustomerRecord.sql")
     .WithIn(new {CustomerId = 2, CustomerName = "John", Address = "124 Street"})
     .Execute();

See the WIKI pages for more documentation on how to use the library.

xpf.Script Change List

xpf.Script.SQLServer Change List