These are the samples mentioned in the Dapper .Net publication on Medium:
Work is still in progress, so come back often to check out new articles and samples. My aim to to publish one article per week, until all feature of Dapper are covered.
Here's the list of samples related to articles published so far:
- Getting Started with Dapper .NET
- Multiple Executions
- Multiple Resultsets
- Multiple Mapping
- SQL Server Features
- Custom Mapping
- Custom Handling
- One-To-Many Relationships
- Complex Custom Handling
Please note that the "One-To-Many Relatioships" and "Complex Custom Handling" points to the same articles since both topics are discussed there as they are strictly related to each other.
To run the "Basic Samples", related to the first article "Getting Started with Dapper .NET", just run
dotnet run -f net48
from
Dapper.Samples.Basics
folder. To run advanced samples you have to move into
Dapper.Samples.Advanced
and then from here you can just run
dotnet run -f net48
to run ALL samples or
dotnet run -f net48 "Sample Name"
to run that specific sample. Eg:
dotnet run -f net48 "Multiple Executions"
to run only the "Multiple Execution" sample.
To have a list of all advanced samples available run:
dotnet run -f net48 -help
Samples are done using .NET Core 3.0 and .NET Framework 4.8: make sure you have them installed it on your machine.
The project supports multiple targets:
- net48
- netcoreapp3.0
To execute the application targeting one specifc framework, just use the -f
option when running the console app:
dotnet run -f net48
more info on the -f
option here:
If you are looking for samples supporting older version, take a look at the previous releases as they support also:
- .NET Framework 4.5.2
- .NET Core 2.0
- Dapper 1.50
Samples also use SQL Server as database server. If you don't have a Windows machine, you can use the Docker version: SQL Server 2017.
SQL Server database file is attached automatically using the LocalDB/MSSQLServer
instance. If you prefer to use a non-local instance, make sure you change the connection string accordingly, and attach the database file to your instance.