DASL.DapperWrapper 1.2.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package DASL.DapperWrapper --version 1.2.2                
NuGet\Install-Package DASL.DapperWrapper -Version 1.2.2                
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="DASL.DapperWrapper" Version="1.2.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DASL.DapperWrapper --version 1.2.2                
#r "nuget: DASL.DapperWrapper, 1.2.2"                
#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 DASL.DapperWrapper as a Cake Addin
#addin nuget:?package=DASL.DapperWrapper&version=1.2.2

// Install DASL.DapperWrapper as a Cake Tool
#tool nuget:?package=DASL.DapperWrapper&version=1.2.2                

Usage:

Setup connection string in App.config and specifiy the name before making any calls to DapperWrapper.

DapperWrapper.ConnectionStringName = "my_db_connection";

Specify your db provider. Currently, MySql and MSSql are supported by this wrapper.

DapperWrapper.DbProvider = DapperWrapper.MYSQL_PROVIDER; // default
DapperWrapper.DbProvider = DapperWrapper.MSSQL_PROVIDER;

Note that some wrapper functions require the [Table(..)] attribute to be explicit.

Assuming this class...

[Table("users")]
public class User
{
    public int Id { get; set; }
    public string AccountCode { get; set; } = string.Empty;
    public string Email { get; set; }  = string.Empty;
    public string Department { get; set; }  = string.Empty;
    public string AccountPassword { get; set; } = string.Empty;
}

var user1 = new User {....};

This is how you use the wrapper.

// inserts
int new_id = DapperWrapper.Insert(user1);
int new_id = await DapperWrapper.InsertAsync(user1);

// query
var user = DapperWrapper.Get<User>(23);
var user = await DapperWrapper.GetAsync<User>(23);
var user = DapperWrapper.GetByKeyField<User>("Email", "foo.bar@emailserver.foobar");
List<User> users = await DapperWrapper.GetAllByKeyField<User>("Department", "IT");


// updates
DapperWrapper.Update(user1);
await DapperWrapper.UpdateAsync(user1);

// delete
DapperWrapper.Delete(user1);

Custom SQL can be sent directly and a parameterized statement is constructed and sent to the database

var sql = "SELECT * FROM `user` WHERE Email=@email AND AccountPassword=@password";
var user = return await DapperWrapper.ExecuteSelectSingleAsync<User>(sql, new { email, password });

There are other available methods.

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.2.6 70 11/13/2024
1.2.5 82 9/23/2024
1.2.4 78 8/2/2024
1.2.3 97 6/20/2024
1.2.2 104 5/21/2024
1.2.1 118 4/27/2024
1.2.0 114 4/21/2024
1.0.3 106 4/21/2024
1.0.2 118 4/20/2024
1.0.1 101 4/19/2024
1.0.0 99 4/19/2024

Package update