Introduction
editMeziantou.Framework.TdsServer is a server for TDS (Tabular Data Stream), the network protocol of SQL Server. Clients such as Microsoft.Data.SqlClient connect to it as they would connect to SQL Server, but your code decides who can log in and what each query returns. There is no database behind it: the library handles the protocol, you provide the answers.
What you can do with it
- Replace SQL Server in tests: start a server on a free port, return the rows your test needs, and check the SQL text and the parameters your application sends. See Getting started.
- Expose your own data over the SQL Server protocol: tools and applications that only know how to talk to SQL Server can query in-memory collections or any
IQueryablesource. See The query engine. - Control logins: check the user name and password of every connection, and pass the identity of the user to the query handlers. See Authentication.
- Answer queries and stored procedure calls: read the SQL text, the procedure name and the typed parameters, and return result sets, informational messages or SQL Server-style errors. See Handling queries and Returning results.
- Receive bulk loads from
SqlBulkCopy. See Bulk loads. - Encrypt connections with TLS, from a PFX file or a PEM certificate and key. See Encryption.
How it works
A connection goes through two callbacks:
- The authentication handler receives the login (user name, password, database, application name) and accepts or rejects it. When it accepts, it can attach a
ClaimsPrincipalto the connection. - The query handler receives each request of the connection: a SQL batch, or a remote procedure call (RPC), which is how clients send stored procedure calls and parameterized queries. It returns the result sets or an error.
You write the query handler yourself, or use the built-in query engine, which runs stored procedures mapped to .NET delegates and translates a subset of SELECT statements to LINQ queries over your IQueryable sources.
The server runs either inside an ASP.NET Core application, on Kestrel, or on its own with the TdsServer class. See Hosting the server.
Namespaces
| Namespace | Contains |
|---|---|
| Meziantou.Framework.Tds | The standalone TdsServer and the server options (TdsServerOptions) |
| Meziantou.Framework.Tds.Handler | The authentication and query callbacks, their contexts and results (TdsResultSet, TdsColumn, …) |
| Meziantou.Framework.Tds.Hosting | The ASP.NET Core integration (AddTdsServer, MapTdsHandlers, …) |
| Meziantou.Framework.Tds.QueryEngine | The built-in query engine (TdsQueryEngineOptions, TdsQueryEngine) |
Next steps
- Getting started: install the package, start a server and query it.
- Connecting clients: the connection strings that work with the server.
- Limitations: what the server does not do.