11.4 C
Canberra
Saturday, July 26, 2025

Tips on how to use Dapper Plus in .NET Core



To put in these packages, choose the undertaking within the Resolution Explorer window, then right-click and choose “Handle NuGet Packages.” Within the NuGet Package deal Supervisor window, seek for the Dapper.Plus and Microsoft.Information.Sqlite packages and set up them.

Alternatively, you’ll be able to set up the Dapper Plus and Dapper packages utilizing the NuGet Package deal Supervisor console by coming into the instructions under.


PM> Set up-Package deal Z.Dapper.Plus
PM> Set up-Package deal Dapper

Insert information in bulk utilizing BulkInsert

To insert bulk information (i.e., a number of entity information) in your database, you’ll be able to reap the benefits of the BulkInsert technique. This technique will insert a number of rows of information within the underlying database desk unexpectedly. Allow us to look at learn how to use the BulkInsert technique to insert bulk information in a database.

Take into account the next C# class.


class Writer
{
    public int AuthorId { get; set; }
    public string FirstName { get; set; } = string.Empty;
    public string LastName { get; set; } = string.Empty;
    public string Deal with { 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 Record GetAuthors()
{
    var authors = new Record()
    {
        new Writer() { AuthorId = 1, FirstName = "Joydip", LastName = "Kanjilal", Deal with = "Hyderabad, India", Cellphone = "1234567890" },
        new Writer() { AuthorId = 2, FirstName = "Steve", LastName = "Smith", Deal with = "Texas, USA", Cellphone = "0987654321" }
    };
    return authors;
}

You map your entity utilizing the DapperPlusManager.Entity technique as proven under. Be aware how the Identification extension technique has been referred to as to configure the id column, i.e., AuthorId on this instance.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles