Microsoft SQL Server implementation of Birko.Data.SQL stores and repositories.
C:\Source\Birko.Data.SQL.MSSql\
- Provides SQL Server-specific data store implementations
- Implements bulk operations using SqlBulkCopy
- MSSql connector management
MSSqlStore<T>- Synchronous SQL Server storeMSSqlBulkStore<T>- Bulk operations storeAsyncMSSqlStore<T>- Asynchronous SQL Server storeAsyncMSSqlBulkStore<T>- Async bulk operations store
MSSqlRepository<T>- SQL Server repositoryMSSqlBulkRepository<T>- Bulk repositoryAsyncMSSqlRepository<T>- Async repositoryAsyncMSSqlBulkRepository<T>- Async bulk repository
MSSqlConnector- SQL Server connection management
Connection string format:
Server=server_address;Database=database_name;User Id=user;Password=password;
Or using integrated security:
Server=server_address;Database=database_name;Integrated Security=True;
using Birko.Data.SQL.MSSql.Stores;
using System.Data.SqlClient;
public class CustomerStore : MSSqlStore<Customer>
{
public override Guid Create(Customer item)
{
var cmd = Connector.CreateCommand();
cmd.CommandText = @"
INSERT INTO Customers (Id, Name, Email)
VALUES (@Id, @Name, @Email)";
cmd.Parameters.AddWithValue("@Id", item.Id);
cmd.Parameters.AddWithValue("@Name", item.Name);
cmd.Parameters.AddWithValue("@Email", item.Email);
cmd.ExecuteNonQuery();
return item.Id;
}
}Uses SqlBulkCopy for efficient bulk inserts:
public override IEnumerable<KeyValuePair<Customer, Guid>> CreateAll(IEnumerable<Customer> items)
{
using (var bulkCopy = new SqlBulkCopy(Connector))
{
bulkCopy.DestinationTableName = "Customers";
// Configure column mappings
// Execute bulk copy
}
}Common SQL Server to .NET type mappings:
UNIQUEIDENTIFIER→GuidNVARCHAR(n)→stringINT→intBIGINT→longDECIMAL(p,s)→decimalDATETIME2→DateTimeBIT→bool
- Birko.Data.Core
- Birko.Data.Stores
- Birko.Data.SQL
- System.Data.SqlClient (or Microsoft.Data.SqlClient)
For tables with identity columns:
cmd.CommandText = "INSERT INTO Customers (Name) VALUES (@Name); SELECT SCOPE_IDENTITY();";Use OUTPUT clause for inserted values:
INSERT INTO Customers (Name)
OUTPUT INSERTED.Id
VALUES (@Name)using (var transaction = Connector.BeginTransaction())
{
try
{
// Operations
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}- Requires SQL Server 2012 or later
- Some features may require specific SQL Server editions
When making changes that affect the public API, features, or usage patterns of this project, update the README.md accordingly. This includes:
- New classes, interfaces, or methods
- Changed dependencies
- New or modified usage examples
- Breaking changes
When making major changes to this project, update this CLAUDE.md to reflect:
- New or renamed files and components
- Changed architecture or patterns
- New dependencies or removed dependencies
- Updated interfaces or abstract class signatures
- New conventions or important notes
Every new public functionality must have corresponding unit tests. When adding new features:
- Create test classes in the corresponding test project
- Follow existing test patterns (xUnit + FluentAssertions)
- Test both success and failure cases
- Include edge cases and boundary conditions