DapperDBHelper 1.7.0

dotnet add package DapperDBHelper --version 1.7.0                
NuGet\Install-Package DapperDBHelper -Version 1.7.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="DapperDBHelper" Version="1.7.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DapperDBHelper --version 1.7.0                
#r "nuget: DapperDBHelper, 1.7.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.
// Install DapperDBHelper as a Cake Addin
#addin nuget:?package=DapperDBHelper&version=1.7.0

// Install DapperDBHelper as a Cake Tool
#tool nuget:?package=DapperDBHelper&version=1.7.0                

To make full use of web APIs, exclude the installation of extra packages by just installing DapperDBHelper.
Create an object of DapperDBHelper and pass your connection string through the constructor of the DBHelper class.

Here's how you can use DapperDBHelper. Below is an example:

public class SetupsController
{
   private readonly DBHelpers _dBHelpers;

   public SetupsController()
   {
       _dBHelpers = new DBHelpers(ConectionString.connectionString);
   }

   public async Task<List<YourViewModelClass>> GetSingleListAsync()
   {
       var result = await _dBHelpers.QueryAsyncList<YourViewModelClass>("SELECT * FROM table");
       return result;
   }

   public YourViewModelClass GetSingleRecord()
   {
       var result = _dBHelpers.Query<YourViewModelClass>("SELECT TOP 1 * FROM table");
       return result;
   }

   public async Task<Dictionary<string, IEnumerable<object>>> GetMultipleTablesAsync(int id)
   {
       // Make a list of table names that your stored procedure returns
       List<string> tableNames = new List<string>
       {
           "Table1",
           "Table2",
           "Table3"
       };

       var result = await _dBHelpers.QueryMultipleAsync("EXEC Store_Procedure @ID", new { ID = id }, tableNames);
       return result;
   }

   // Execute Method is used for CRUD operations
   // After execution of your stored procedure, returning a single row of current execution is a best practice
   // ExecuteAsync call depends upon your application nature
   public async Task<int> InsertDataAsync(Employees model)
   {
       var result = await _dBHelpers.ExecuteAsync("EXEC Store_Procedure @FirstName, @LastName, @Address", new { FirstName = model.FirstName, LastName = model.LastName, Address = model.Address });
       return result;
   }
}




For .NET 8, you can use the following code:


// Register your service here
builder.Services.AddTransient<DBHelpersForAllDatabases>();

// Register your database connection
builder.Services.AddTransient<IDbConnection>(_ => new SqlConnection(Configuration.GetConnectionString("DefaultConnection")));

public class MyController : ControllerBase
{
   private readonly DBHelpersForAllDatabases _dbHelpers;

   public MyController(DBHelpersForAllDatabases dbHelpers)
   {
       _dbHelpers = dbHelpers;
   }

   [HttpGet]
   public async Task<IActionResult> Get()
   {
       // Use DBHelpers to execute queries
       var result = await _dbHelpers.QueryAsyncList<MyModel>("SELECT * FROM MyTable");
       return Ok(result);
   }
}


In this setup:

GetSingleListAsync: Asynchronously retrieves a list of records from a table.
GetSingleRecord: Retrieves a single record from a table.
GetMultipleTablesAsync: Executes a stored procedure that returns multiple tables and maps them to a dictionary.
InsertDataAsync: Executes a stored procedure to insert data into a table.
Make sure to adjust the method signatures and implementations to match your specific use case and requirements. This setup allows you to effectively manage database interactions using DapperDBHelper in a streamlined manner.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows 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
1.7.0 176 6/28/2024
1.6.0 100 6/13/2024
1.5.0 111 6/7/2024
1.4.0 1,349 8/2/2022
1.3.0 1,593 4/10/2021
1.2.0 1,179 1/28/2021
1.1.0 1,200 1/25/2021
1.0.0 1,154 1/24/2021