SqlFlow.SqlServer
1.0.1
dotnet add package SqlFlow.SqlServer --version 1.0.1
NuGet\Install-Package SqlFlow.SqlServer -Version 1.0.1
<PackageReference Include="SqlFlow.SqlServer" Version="1.0.1" />
<PackageVersion Include="SqlFlow.SqlServer" Version="1.0.1" />
<PackageReference Include="SqlFlow.SqlServer" />
paket add SqlFlow.SqlServer --version 1.0.1
#r "nuget: SqlFlow.SqlServer, 1.0.1"
#:package SqlFlow.SqlServer@1.0.1
#addin nuget:?package=SqlFlow.SqlServer&version=1.0.1
#tool nuget:?package=SqlFlow.SqlServer&version=1.0.1
SqlFlow
SqlFlow is a lightweight SQL Server helper library for .NET Framework applications. It is designed for developers who want full control over SQL without using ORMs.
SqlFlow focuses on simplicity, clarity, and classic ADO.NET patterns.
Target Framework:
- .NET Framework 4.7.2
- Best suited for WinForms and WPF applications
Installation: Install SqlFlow from NuGet using: Install-Package SqlFlow.SqlServer
Create Agent: Create one Agent instance and reuse it across your application.
var agent = new Agent( "localhost", "TestDb", new ConnectionOptions(), new AgentOptions());
agent.Error += Agent_Error;
Check Database Connection: Use this to verify database connectivity.
bool ok = agent.CheckConnection(); if (!ok) { MessageBox.Show("Cannot connect to database."); }
Query (DataTable): Execute a SELECT query and get a DataTable.
DataTable dt = agent.Query( "SELECT * FROM usr_Users WHERE Id = @Id", new SqlParameter("@Id", 1));
Query Single Value: Retrieve a single column value from a query result.
object username = agent.Query( "SELECT Username FROM usr_Users WHERE Id = @Id", "Username", new SqlParameter("@Id", 1));
Returns the value of the specified column. Returns null if no rows are found.
Execute (INSERT / UPDATE / DELETE): Execute a non-query command.
int rows = agent.Execute( "UPDATE usr_Users SET Username = @U WHERE Id = @Id", new SqlParameter("@U", "TestUser"), new SqlParameter("@Id", 1));
Returns the number of affected rows.
Insert and Get New ID: Insert a record and retrieve the newly generated IDENTITY value.
int newId = agent.ExecuteInsertId( "INSERT INTO usr_Users (Username) OUTPUT INSERTED.Id VALUES (@U)", new SqlParameter("@U", "TestUser"));
Error Handling (WinForms Example): SqlFlow exposes a single error event with error classification.
private void Agent_Error(object sender, SqlFlowErrorEventArgs e) { switch (e.ErrorType) { case SqlFlowErrorType.Timeout: MessageBox.Show("Database timeout."); break;
case SqlFlowErrorType.DuplicateKey:
MessageBox.Show("Duplicate record.");
break;
case SqlFlowErrorType.ForeignKeyViolation:
MessageBox.Show("Foreign key violation.");
break;
case SqlFlowErrorType.LoginFailed:
MessageBox.Show("Database login failed.");
break;
default:
MessageBox.Show(e.Exception.Message);
break;
}
}
Features:
- Simple Query and Execute API
- SQL parameter validation
- Insert-and-return-ID helper
- Error classification
- Centralized error event
- No ORM, no magic
- Designed for classic .NET applications
Design Philosophy:
- Explicit SQL
- Predictable behavior
- No hidden retries
- No abstraction layers
- Easy to debug and maintain
Author: Zacharias Travagiakis
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
-
.NETFramework 4.7.2
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release.
Includes Query, Execute, InsertAndGetId, error classification, and CheckConnection.