Learn extra at:
To put in these packages, choose the undertaking within the Resolution Explorer window, then right-click and choose “Handle NuGet Packages.” Within the NuGet Bundle Supervisor window, seek for the Dapper.Plus and Microsoft.Knowledge.Sqlite packages and set up them.
Alternatively, you may set up the Dapper Plus and Dapper packages utilizing the NuGet Bundle Supervisor console by coming into the instructions under.
PM> Set up-Bundle Z.Dapper.Plus
PM> Set up-Bundle Dapper
Insert information in bulk utilizing BulkInsert
To insert bulk information (i.e., a number of entity information) in your database, you may reap the benefits of the BulkInsert
methodology. This methodology will insert a number of rows of knowledge within the underlying database desk all of sudden. Allow us to study find out how to use the BulkInsert
methodology to insert bulk information in a database.
Think about the next C# class.
class Creator
{
public int AuthorId { get; set; }
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public string Tackle { get; set; } = string.Empty;
public string Cellphone { get; set; } = string.Empty;
}
The code given under illustrates how one can create a listing of authors, populate information, and return the checklist.
static Listing GetAuthors()
{
var authors = new Listing()
{
new Creator() { AuthorId = 1, FirstName = "Joydip", LastName = "Kanjilal", Tackle = "Hyderabad, India", Cellphone = "1234567890" },
new Creator() { AuthorId = 2, FirstName = "Steve", LastName = "Smith", Tackle = "Texas, USA", Cellphone = "0987654321" }
};
return authors;
}
You map your entity utilizing the DapperPlusManager.Entity
methodology as proven under. Be aware how the Identification
extension methodology has been known as to configure the id column, i.e., AuthorId
on this instance.