DapperDBHelper 1.6.0
See the version list below for details.
dotnet add package DapperDBHelper --version 1.6.0
NuGet\Install-Package DapperDBHelper -Version 1.6.0
<PackageReference Include="DapperDBHelper" Version="1.6.0" />
paket add DapperDBHelper --version 1.6.0
#r "nuget: DapperDBHelper, 1.6.0"
// Install DapperDBHelper as a Cake Addin #addin nuget:?package=DapperDBHelper&version=1.6.0 // Install DapperDBHelper as a Cake Tool #tool nuget:?package=DapperDBHelper&version=1.6.0
Use full for web API’s
Excludes the installation of extra packages just installs DapperDBHelper and create object of DapperDBHelper and pass your connection string through contractor DBHelper class.
How we can use DapperDBHelper, Find the piece of code below Example
public class SetupsController
{
private readonly DBHelpers _dBHelpers;
public SetupsController()
{
_dBHelpers = new DBHelpers(ConectionString.connectionString);
}
Public async void getSingleList()
{
var Result = await _dBHelpers.QueryAsyncList<YourViewModelClass>("Select * from table");
}
public void getSingleRecord()
{
var Result = _dBHelpers.Query<YourViewModelClass>("Select Top 1* from table");
}
public void getMultipleTable()
{
Make list same as it is like table returns from your store procedure
List<string> tableName = new List<string>();
tableName.Add("Table1");
tableName.Add("Table2");
tableName.Add("Table3");
var Result = await _dBHelpers.QueryMultipleAsync("EXEC Store_Procedure @ID", param: new { ID = ID }, tableName);
}
Execute Method is used for CRUD Operations
After Execution of your store procedure returning single row of current execution is best practice
ExecuteAsync call depends upon your application nature
public void InserData(Employees model)
{
var Result = await _dBHelpers.Execute("EXEC Store_Procedure @FirstName,@LastName,@Address", param: new { FirstName = model.FirstName, LastName =model.LastName, Address = model.Address});
}
-- For .NET 8 following Code do the help--
// 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);
}
}
Product | Versions 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. |
-
net8.0
- Dapper (>= 2.1.35)
- FirebirdSql.Data.FirebirdClient (>= 10.2.0)
- Microsoft.Data.Sqlite.Core (>= 8.0.6)
- MySql.Data (>= 8.4.0)
- Newtonsoft.Json (>= 13.0.3)
- Npgsql (>= 8.0.3)
- System.Configuration.ConfigurationManager (>= 8.0.0)
- System.Data.Common (>= 4.3.0)
- System.Data.SqlClient (>= 4.8.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.