FourConnected.DapperExtension.Core 2.0.0

.NET Core 3.1
Install-Package FourConnected.DapperExtension.Core -Version 2.0.0
dotnet add package FourConnected.DapperExtension.Core --version 2.0.0
<PackageReference Include="FourConnected.DapperExtension.Core" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FourConnected.DapperExtension.Core --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FourConnected.DapperExtension.Core, 2.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install FourConnected.DapperExtension.Core as a Cake Addin
#addin nuget:?package=FourConnected.DapperExtension.Core&version=2.0.0

// Install FourConnected.DapperExtension.Core as a Cake Tool
#tool nuget:?package=FourConnected.DapperExtension.Core&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Updated to support .NET Core 3.1 And support Column Encryption in SQL

Added TableMap attribute to support class map to other schema and table name Example: [TableMap("dbo", nameof(Address))] public class Address { } It will map the class to [dbo].[Address] table

[TableMap("cus", "CustomerAddress")] public class Address { } It will map the class to [cus].[CustomerAddress] table

Added ColumnMap to support column different than class property name Example: [ColumnMap("IsUSCompany")] public bool IsLocalCompany { get; set; }

Full example below

-- SQL -- Set up tables

 -- NOTE: all able must as primary key!!
 
 -- Create Address table
 CREATE TABLE [dbo].[Address](
 	[Id]     [uniqueidentifier]     NOT NULL,
    [AddressLine1] [nvarchar] (500) NULL,
	[CustomerId] [uniqueidentifier] NULL,
	[City] [nvarchar] (50) NULL,
	[Country] [nvarchar] (50) NULL,
CONSTRAINT[PK_Address] PRIMARY KEY CLUSTERED
( 
[Id] ASC
)WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON[PRIMARY]
) ON[PRIMARY]
 -- Create new schema for accounting [acc]

CREATE Schema [acc] GO -- Create Customer table CREATE TABLE[acc].[Customer] ( [Id] [uniqueidentifier] NOT NULL, [Name] [nvarchar] (50) NULL, CONSTRAINT[PK_Customer] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON[PRIMARY] ) ON[PRIMARY] GO

/// C# Code

class Program
{
    static void Main(string[] args)
    {
        var connecton = new SqlConnection("Server=localhost; Database=<database Name>; Trusted_Connection=True");
        Console.WriteLine("Insert Customer");
        var customer = new MyCustomer()
        {
            Id = Guid.NewGuid(),
            CustomerName = "Hello Joe"
        };

        var sql = connecton.InsertOrUpdate(null, customer);

        var addresses = new List<Address>();
        // create 100 address
        for (var i = 0; i<100; i++)
        {
            addresses.Add(new Address()
            {
                Id = Guid.NewGuid(),
                AddressLine1 = $"Test Address {i}",
                City = $"City {i}",
                Country = "USA",

                CustomerId = customer.Id    
            });
        }

        // use SQL bulkInsert to insert them add at once
        connecton.BulkInsert(null, addresses);
    }
}

/// <summary>
/// Address class
/// [TableMap("dbo","Address")] is optional where by default classes will map to [dbo].[{ClassName}]
/// </summary>
[TableMap("dbo","Address")]
public class Address
{
    public Guid Id { get; set; }
    public string AddressLine1 { get; set; }
    public string City { get; set; }
    public string Country { get; set; }

    public Guid CustomerId { get; set; }
}

/// <summary>
/// MyCustomer class
/// Map MyCustomer to [acc].[Customer] table
/// </summary>

[TableMap("acc", "Customer")]
public class MyCustomer
{
    public Guid Id { get; set; }

    /// <summary>
    /// Try to map the CustomerName to table column "Name"
    /// </summary>
    [ColumnMap("Name")]
    public string CustomerName { get; set; }
}
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
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
2.0.0 286 12/16/2020
1.0.1 402 5/10/2019