DASL.DapperWrapper
1.2.2
There is a newer version of this package available.
See the version list below for details.
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- BouncyCastle.Cryptography (>= 2.3.1)
- Dapper (>= 2.1.35)
- Dapper.Contrib (>= 2.0.78)
- MySql.Data (>= 8.4.0)
- MySqlConnector (>= 2.3.7)
- System.Data.SqlClient (>= 4.8.6)
- System.Drawing.Common (>= 8.0.5)
- Z.Dapper.Plus (>= 7.4.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Package update