DBHelper.NET 5.1.0

dotnet add package DBHelper.NET --version 5.1.0
                    
NuGet\Install-Package DBHelper.NET -Version 5.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DBHelper.NET" Version="5.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DBHelper.NET" Version="5.1.0" />
                    
Directory.Packages.props
<PackageReference Include="DBHelper.NET" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DBHelper.NET --version 5.1.0
                    
#r "nuget: DBHelper.NET, 5.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DBHelper.NET@5.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DBHelper.NET&version=5.1.0
                    
Install as a Cake Addin
#tool nuget:?package=DBHelper.NET&version=5.1.0
                    
Install as a Cake Tool

DBHelper.NET DBHelper.NET is a powerful and extensible .NET library designed to simplify SQL Server database operations. It provides a rich set of helper methods for querying, updating, and managing data using ADO.NET, LINQ, and even API-based access.

๐Ÿ“ฆ Installation Install via NuGet Package Manager:

Install-Package DBHelper.NET

Or via .NET CLI:

dotnet add package DBHelper.NET

๐Ÿš€ Features Data Lookup Helpers: DLookup, DMax, DMin, DFirst, DLast, DSum, DAverage, DCount Existence Checks: Exist methods to verify record presence Update Helpers: DUpdate for updating records Direct SQL Execution: ExecuteReaderQuery, ExecuteNonReader API Integration: Execute SQL queries via web APIs with JSON serialization Record Management: Save and Delete methods for class-based persistence Lambda to SQL Translation: Convert LINQ expressions to SQL WHERE clauses File Transfer Support: Upload and download files via API

๐Ÿง  Usage Examples Lookup a Value

		string connStr = "...";
		var name = DBHelper.DLookup<string>(connStr, "Name", "Users", "Id = 1");
		
	Count Records
		long count = conn.DCount("*", "Orders", "Status = 'Pending'");
		
	Update a Record
		int rowsAffected = conn.DUpdate("Status", "Orders", "Id = 1", "Completed");
		
	Execute SQL Query
		DataTable dt = conn.ExecuteReaderQuery("SELECT * FROM Products
		
	Save a Class Object
		var product = new Product { Id = 1, Name = "Widget", Price = 9.99 };
		product.Save(connStr);
	
	Lambda to SQL
		string sqlWhere = LambdaToSqlTranslator.Translate<Product>(p => p.Price > 10 && p.IsActive);
		
	API Integration
		DataTable dt = conn.ExecuteReaderQuery("SELECT * FROM Products", "your-api-key", "https://api.example.com");
	
	File Transfer
		bool uploaded = DBHelper.UploadFile("local/file.txt", "/server/path", "api-key", "https://api.example.com");
		

Class Oriented Usage ๐Ÿ’พ Saving a Class Object To use the Save<T> method, your class must:

	Be a public class.
	Include a public field named KeyList containing a comma-separated list of key property names.
	Have properties that match the column names in the corresponding SQL table.
	๐Ÿงช Example: Saving a Product Object
		
		public class Product
		{
			// Required: Comma-separated list of key fields
			public static string KeyList = "Id";

			// Properties must match SQL table column names
			public int Id { get; set; }
			public string Name { get; set; }
			public decimal Price { get; set; }
			public bool IsActive { get; set; }
		}
		
๐Ÿ’ก Save a Single Record
	
	var product = new Product
	{
		Id = 1,
		Name = "Super Widget",
		Price = 19.99m,
		IsActive = true
	};

	int result = product.Save(connectionString);

๐Ÿ’ก Save a List of Records var products = new List<Product> { new Product { Id = 1, Name = "Widget A", Price = 9.99m, IsActive = true }, new Product { Id = 2, Name = "Widget B", Price = 14.99m, IsActive = false } };

int result = products.Save(connectionString);

		

๐Ÿงฉ Requirements .NET Framework 4.6.1+ or .NET Core 3.1+ SQL Server Newtonsoft.Json

๐Ÿ“„ License MIT License

Product Compatible and additional computed target framework versions.
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.1.0 87 7/29/2025
5.0.0 133 1/27/2025
4.0.0 563 8/18/2022
3.0.0 461 8/3/2022
2.0.0 453 7/28/2022
1.0.0 468 7/27/2022

Added a ODBC connection manager.