Simplify.FluentNHibernate 2.5.1

.NET Standard 2.0 .NET Framework 4.6.2
Install-Package Simplify.FluentNHibernate -Version 2.5.1
dotnet add package Simplify.FluentNHibernate --version 2.5.1
<PackageReference Include="Simplify.FluentNHibernate" Version="2.5.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Simplify.FluentNHibernate --version 2.5.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Simplify.FluentNHibernate, 2.5.1"
#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 Simplify.FluentNHibernate as a Cake Addin
#addin nuget:?package=Simplify.FluentNHibernate&version=2.5.1

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

Simplify.FluentNHibernate Documentation

Provides:

  • FluentConfiguration class extensions which allows you to easily configure your data-base connection.
  • NHibernate ISession extensions which allows you to write queries with lambda expressions.
  • SchemaExporter, SchemaUpdater

Available at NuGet as binary package

Quick Start Example

Configuration through Microsoft.Extensions.Configuration

Session factory setup
namespace MyApp.Database
{
        public class MyDbSessionFactoryBuilder
        {
                private readonly ISessionFactory _instance;

                public ISessionFactory Instance
                {
                        get { return _instance; }
                }

                public MyDbSessionFactoryBuilder(IConfiguration cfg, string configSectionName = "MyDatabaseConnectionSettings")
                {
                        var configuration = Fluently.Configure();
                        configuration.InitializeFromConfigMsSql(cfg, configSectionName);
                        configuration.AddMappingsFromAssemblyOf<MyDbSessionFactoryBuilder>();
                        _instance = configuration.BuildSessionFactory();
                }
        }
}
IConfiguration settings example based on appsettings.json
{
    "MyDatabaseConnectionSettings":
    {
        "ServerName": "Server name",
        "DataBaseName": "data-base name",
        "UserName": "user name",
        "UserPassword": "password",
    }
}

Configuration through *.config files

Session factory setup
namespace MyApp.Database
{
        public class MyDbSessionFactoryBuilder
        {
                private readonly ISessionFactory _instance;

                public ISessionFactory Instance
                {
                        get { return _instance; }
                }

                public MyDbSessionFactoryBuilder(string configSectionName = "MyDatabaseConnectionSettings")
                {
                        var configuration = Fluently.Configure();
                        configuration.InitializeFromConfigMsSql(configSectionName);
                        configuration.AddMappingsFromAssemblyOf<MyDbSessionFactoryBuilder>();
                        _instance = configuration.BuildSessionFactory();
                }
        }
}
Configuration file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
        <configSections>
                <section name="MyDatabaseConnectionSettings" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        </configSections>

        <MyDatabaseConnectionSettings>
                <add key="ServerName" value="Server name" />
                <add key="DataBaseName" value="data-base name" />

                <add key="UserName" value="user name" />
                <add key="UserPassword" value="password" />
        </MyDatabaseConnectionSettings>
</configuration>

FluentNHibernate quick setup variants

Database type Method Comment
Microsoft SQL Server InitializeFromConfigMsSql Connection using System.Data managed driver
MySQL InitializeFromConfigMySql Connection using MySql.Data managed driver
PostgreSQL InitializeFromConfigPostgreSql Connection using Npgsql managed driver
Oracle InitializeFromConfigOracleOdpNet Connection using Oracle.ManagedDataAccess managed driver (recommended for Oracle)
Oracle InitializeFromConfigOracleOdpNetNative Connection using odp.net.x86 or odp.net.x64 unmanaged drivers
Oracle InitializeFromConfigOracleClient Connection using Oracle.DataAccess.x86 or Oracle.DataAccess.x64 unmanaged drivers
SQLite InitializeFromConfigSqLite Connection using System.Data.SQLite managed driver
SQLite InitializeFromConfigSqLiteInMemory Connection using System.Data.SQLite managed driver using in-memory database

Additional configuration options

Option Name Type Description
Port int Database port number
ShowSql bool Executed SQL queries can be displayed in console/(VS output window) by setting ShowSql option, default values is false

Custom NHibernate configuration

Can be specified via lambda extension, for example, a custom dialect

configuration.InitializeFromConfigMsSql(configSectionName, c => c.Dialect<MsSql2012Dialect>());

Session lambda extensions for data retrieval

Example

var user = session.GetSingleObject(x => x.Name == "FooName");
var users = session.GetList(x => x.Name.StartWith("A"));

More examples here

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 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
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 (1)

Showing the top 1 NuGet packages that depend on Simplify.FluentNHibernate:

Package Downloads
Simplify.Repository.FluentNHibernate

Simplify.Repository FluentNHibernate implementation

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.5.1 945 10/27/2021
2.5.0 1,392 1/21/2021
2.4.0 720 11/17/2020
2.3.0 623 10/7/2020
2.2.0 1,857 4/17/2020
2.2.0-pre01 315 4/17/2020
2.1.0 756 3/4/2020
2.0.0 1,098 10/28/2019
1.9.0 4,498 12/13/2018
1.8.0 1,270 5/6/2018
1.7.0 748 3/5/2018
1.6.0 1,201 2/9/2017
1.5.1 782 1/23/2017
1.5.0 701 8/29/2016
1.4.0 734 8/18/2016
1.3.0 987 1/24/2016
1.2.1 1,090 10/7/2015
1.2.0 1,411 12/22/2014
1.1.0 1,174 11/12/2014
1.0.2-alpha 739 9/8/2014
1.0.1 1,208 4/23/2014
1.0.0 910 2/25/2014