Donald 1.0.0

.NET Standard 2.0
There is a newer version of this package available.
See the version list below for details.
dotnet add package Donald --version 1.0.0
NuGet\Install-Package Donald -Version 1.0.0
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="Donald" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Donald --version 1.0.0
#r "nuget: Donald, 1.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 Donald as a Cake Addin
#addin nuget:?package=Donald&version=1.0.0

// Install Donald as a Cake Tool
#tool nuget:?package=Donald&version=1.0.0

Donald

Build Status

Meet Donald.

If you're a programmer and have used a database, he's impacted your life in a big way.

This library is named after him.

Getting Started

If you came looking for an ORM, this is not your light saber. May the force be with you.

Donald is a library that aims to make working with ADO.NET a little bit simpler.

Providing basic functional wrappers for the IDbCommand methods ExecuteNonQuery(), ExecuteScalar() & ExecuteReader().

Install the Donald NuGet package:

PM>  Install-Package Donald

Or using the dotnet CLI

dotnet add package Donald

Example

A script is worth a thousand words:

// ------------
// An example using SQL Server
// ------------
open System.Data.SqlClient

let connectionString = 
    "Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;"


// Created our strongly typed DbConnectionFactory
let connectionFactory : DbConnectionFactory = 
    fun _ -> new SqlConnection(connectionString) :> IDbConnection


// Define our model
type Author = 
    {
        AuthorId : int
        FullName : string
    }
    // Not mandatory, but helpful
    static member fromReader (rd : IDataReader) = 
        {
            AuthorId = rd.GetInt32("author_id")  // IDataReader extension method
            FullName = rd.GetString("full_name") // IDataReader extension method
        }


// Find author's by name
let findAuthor search =
    use conn = createConn connectionFactory

    query
         "SELECT author_id, full_name
         FROM   author
         WHERE  full_name LIKE @search"
        [ newParam "search" search ]
        Author.fromReader
	conn


// Create a new author
let insertAuthor fullName =
    use conn = createConn connectionFactory
    use tran = beginTran conn // Base function's are transaction-oriented
    
    let authorId = 
        tranScalar // ExecuteScalar() within scope of transaction
            "INSERT INTO author (full_name) VALUES (@full_name);
             SELECT SCOPE_IDENTITY();"
            [ newParam "full_name" fullName]
            Convert.ToInt32 // Any obj -> int function would do here
	    tran

    commitTran tran

    authorId 


// Update an existing author
let updateAuthor author =
    use conn = createConn connectionFactory
    use tran = beginTran conn 

    tranExec // ExecuteNonQuery() within scope of transaction
        "UPDATE author SET full_name = @full_name WHERE author_id = @author_id"
        [ 
            newParam "author_id" author.AuthorId
            newParam "full_name" author.FullName
        ]
        tran

    commitTran tran // safely commit transaction


// Retrieve author by id
let getAuthor authorId =
    use conn = createConn connectionFactory

    querySingle // Returns Option<Author>
        "SELECT author_id, full_name
         FROM   author
         WHERE  author_id = @author_id"
         [ newParam "author_id" authorId ]
         Author.fromReader 
	 conn

Find a bug?

There's an issue for that.

License

Built with ♥ by Pim Brouwers in Toronto, ON. Licensed under Apache License 2.0.

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 net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
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
10.0.0-alpha1 19 2/3/2023
9.0.1 109 1/11/2023
9.0.0 126 12/23/2022
8.0.2 172 11/23/2022
8.0.1 138 11/23/2022
8.0.0 139 11/23/2022
7.1.0 2,142 12/17/2021
7.0.0 210 12/14/2021
7.0.0-alpha1 193 11/1/2021
6.2.5 480 8/4/2021
6.2.4 263 8/4/2021
6.2.3 274 7/30/2021
6.2.2 302 7/27/2021
6.2.1 228 7/27/2021
6.2.0 304 7/26/2021
6.1.0 307 7/6/2021
6.1.0-beta3 138 7/5/2021
6.1.0-beta2 170 7/4/2021
6.1.0-beta1 251 7/4/2021
6.0.0 281 4/11/2021
5.1.3 273 3/29/2021
5.1.2 329 2/27/2021
5.1.1 333 1/23/2021
5.0.1 872 12/3/2020
5.0.0 302 12/1/2020
5.0.0-alpha3 219 12/1/2020
5.0.0-alpha2 209 11/30/2020
5.0.0-alpha1 190 11/30/2020
4.0.0 331 11/12/2020
3.0.4 1,024 10/31/2020
3.0.3 642 8/2/2020
3.0.2 391 7/17/2020
3.0.1 380 7/14/2020
3.0.0 420 6/29/2020
2.0.2 352 5/1/2020
2.0.1 341 4/27/2020
2.0.0 330 4/27/2020
1.0.6 332 4/24/2020
1.0.4 337 4/24/2020
1.0.3 338 4/24/2020
1.0.2 345 4/24/2020
1.0.1 537 4/18/2020
1.0.0 379 4/5/2020