BertoSoftware.DapperContext 0.2.1-alpha

This is a prerelease version of BertoSoftware.DapperContext.
There is a newer version of this package available.
See the version list below for details.
dotnet add package BertoSoftware.DapperContext --version 0.2.1-alpha
                    
NuGet\Install-Package BertoSoftware.DapperContext -Version 0.2.1-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BertoSoftware.DapperContext" Version="0.2.1-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BertoSoftware.DapperContext" Version="0.2.1-alpha" />
                    
Directory.Packages.props
<PackageReference Include="BertoSoftware.DapperContext" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BertoSoftware.DapperContext --version 0.2.1-alpha
                    
#r "nuget: BertoSoftware.DapperContext, 0.2.1-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BertoSoftware.DapperContext@0.2.1-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BertoSoftware.DapperContext&version=0.2.1-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=BertoSoftware.DapperContext&version=0.2.1-alpha&prerelease
                    
Install as a Cake Tool

DapperContext

A simple collections of functions and method for CRUD operation in Dapper for generic item.

Version

2025-05-16

0.2.0 - Alpha version

  • No changes

2025-05-13

0.1.0 - Alpha version

How to use

  1. Add a reference to the DapperContext project in your project.
  2. Add a using statement to the DapperContext namespace in your code file.
  3. Create a new instance of the DapperContext class, passing in your database connection string.
  4. Use the methods provided by the DapperContext class to perform CRUD operations on your database.
  5. Dispose of the DapperContext instance when you're done using it.
  6. Optionally, you can use the DapperContext class to perform other database operations, such as executing raw SQL queries or stored procedures.

Create a model

A simple data model

VB.NET

Imports Dapper.Contrib.Extensions

Namespace Model

    <Table("Person")>
    Public Class Person
        <Key>
        Public Property ID As Integer
        Public Property Name As String
        Public Property Surname As String   
        Public Property Address As String

    End Class
End Namespace

C#

using Dapper.Contrib.Extensions;

namespace Model
{

    [Table("Person")]
    public partial class Person
    {
        [Key]
        public int ID { get; set; }
        public string Name { get; set; }
        public string Surname { get; set; }
        public string Address { get; set; }

    }
}

A simple use might look like this:

VB.NET

Imports System

Module Program
    Sub Main(args As String())

        'Add new value into Person Table
        Using ctx As New DapperContext

            Dim person As New Model.Person With {
                .Name = "John",
                .Surname = "Doe"
                .Address = "Street 23"
            }

            ctx.InsertOrUpdate(person)
        End Using

    End Sub
End Module

C#


internal static partial class Program
{
    public static void Main(string[] args)
    {

        // Add new value into Person Table
        using (var ctx = new DapperContext())
        {

            var person = new Model.Person()
            {
                Name = "John",
                Surname = "Doe"
                Address = "Street 23"
            };

            ctx.InsertOrUpdate(person);
        } 

    }
}

Dipendencies

  • You have to install Dapper.Contrib and assign to a model the [Key] attribute on ID field

Note

  • The InsertOrUpdate method works only if the ‘Key’ attribute has been set to a field of type integer.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on BertoSoftware.DapperContext:

Package Downloads
BertoSoftware.DapperAuditContext

A simple collections of functions and method for CRUD operation in Dapper for generic item with an integrated audit system.

BertoSoftware.DapperContext.SqlServer

A simple collections of functions and method for CRUD operation in Dapper for generic item

BertoSoftware.DapperContext.MySql

A simple collections of functions and method for CRUD operation in Dapper for generic item

BertoSoftware.DapperContext.SQLite

A simple collections of functions and method for CRUD operation in Dapper for generic item

BertoSoftware.DapperContext.PostgreSQL

A simple collections of functions and method for CRUD operation in Dapper for generic item

GitHub repositories

This package is not used by any popular GitHub repositories.

v0.2.0.0-alpha

- No changes