Donald 1.0.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.
<PackageVersion Include="Donald" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Donald" />
                    
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 Donald --version 1.0.0
                    
#r "nuget: Donald, 1.0.0"
                    
#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 Donald@1.0.0
                    
#: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=Donald&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Donald&version=1.0.0
                    
Install as a Cake Tool

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 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.  net9.0 was computed.  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 Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Donald:

Package Downloads
FractalDb

A lightweight F# document database built on SQLite with LINQ-style query expressions

MigrondiUI

This is a simple SQL migrations tool Write your Migration SQL apply them or revert them from your database.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.1.0 8,833 3/20/2024
10.0.2 1,341 12/12/2023
10.0.1 1,101 7/11/2023
10.0.0 553 7/8/2023
10.0.0-alpha3 348 2/11/2023
10.0.0-alpha2 330 2/4/2023
10.0.0-alpha1 308 2/3/2023
9.0.1 1,508 1/11/2023
9.0.0 490 12/23/2022
8.0.2 33,647 11/23/2022
8.0.1 491 11/23/2022
8.0.0 563 11/23/2022
7.1.0 2,952 12/17/2021
7.0.0 527 12/14/2021
7.0.0-alpha1 460 11/1/2021
6.2.5 834 8/4/2021
6.2.4 577 8/4/2021
6.2.3 584 7/30/2021
6.2.2 727 7/27/2021
1.0.0 741 4/5/2020
Loading failed