FourConnected.DapperExtension.Core
2.0.0
See the version list below for details.
dotnet add package FourConnected.DapperExtension.Core --version 2.0.0
NuGet\Install-Package FourConnected.DapperExtension.Core -Version 2.0.0
<PackageReference Include="FourConnected.DapperExtension.Core" Version="2.0.0" />
paket add FourConnected.DapperExtension.Core --version 2.0.0
#r "nuget: FourConnected.DapperExtension.Core, 2.0.0"
// 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
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 Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Dapper (>= 2.0.78)
- FastMember.NetCore (>= 1.1.0)
- System.Data.SqlClient (>= 4.6.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.