An extension to the Microsoft SQL Server Compact Edition client library, which simulates the support of the multiple statements in a single command.
C#
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
packages
src/Lyare.SqlServerCe.MultiQuery
tests
.gitignore
LICENSE.txt
README.md readme & nuspec Feb 26, 2014

README.md

Lyare.SqlServerCe.MultiQuery

An extension to the Microsoft SQL Server Compact Edition client library, which simulates the support of the multiple statements in a single command. With the help of this package, you can use the same code to execute queries on both the full SQL Server edition and Compact Edition.

Installation

Lyare.SqlServerCe.MultiQuery library

Use NuGet to install the package into an existing application (assembly is signed):

PM> Install-Package Lyare.SqlServerCe.MultiQuery

or download and build from source code.

Usage

The only thing to do is to wrap an existing command instance into a multi-query command (extension methods are included in the library):

var factory = DbProviderFactories.GetFactory("System.Data.SqlServerCe.4.0");
using (var conn = factory.CreateConnection())
{
	conn.ConnectionString = "Data Source=.;Initial Catalog=Shop;Integrated Security=true";
	conn.Open();
	var cmd = conn.CreateCommand().MultiQuery(); 
    // var cmd = conn.CreateMultiQueryCommand();
	cmd.CommandText = "INSERT INTO Customers values('Customer Name'); SELECT MAX(Id) FROM Customers;";
	var id = (int)cmd.ExecuteScalar();
}

Remarks

  • The command text is split into multiple sub commands only when "CommandType" property of a command is equal to "CommandType.Text".
  • This library is not dependent on the Microsoft SQL Server Compact Edition library and will split the query of a commands of any type, so it is up to developer to decide when to wrap the original command with a multi-query implementation and when not.

License

Lyare.SqlServerCe.MultiQuery is copyrighted under the MIT license.