Connecting to SQL Server with DataProvider

· DataProvider Team

Connecting to SQL Server with DataProvider is straightforward. This guide shows you how to set up your connection and start querying.

Setup

First, install the SQL Server provider:

dotnet add package DataProvider.SqlServer

Connection

Create your connection:

using DataProvider.SqlServer;

var connectionString = "Server=localhost;Database=MyDb;...";
using var connection = new SqlConnection(connectionString);
var provider = new SqlServerProvider(connection);

Querying

Now you can execute queries:

var customers = provider.Query<Customer>(
    "SELECT * FROM Customers WHERE Active = 1"
);

Check out the full documentation for more details.

.NET SQL Database