xpf.Script

A base library for accessing various scripting engines such as SQL Server, Powershell and Razor etc. This is the base library used to develop support for specific scripting engines. See product web site for details on supported scripting systems.


Keywords
Scripting, xpf.Script
License
MS-PL
Install
Install-Package xpf.Script -Version 0.2.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