Skip to content

Instantly share code, notes, and snippets.

View jand187's full-sized avatar

Jan Daniel Anderse jand187

View GitHub Profile
@jand187
jand187 / gist:4537021
Created January 15, 2013 07:53
Basic setup for Fluent NHibernate SQL-Server
var sessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008
.ConnectionString(@"Data Source=.\<instance>;Initial Catalog=<database>;Integrated Security=True")
.ShowSql())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<AdjecentType>())
.ExposeConfiguration(cfg =>
{
var schemaExport = new SchemaExport(cfg);
schemaExport.Execute(true, true, false);
})
@jand187
jand187 / gist:4537031
Last active December 11, 2015 03:19
Basic setup for Fluent NHibernate SQLite.InMemory
var sessionFactory = Fluently.Configure()
.Database(SQLiteConfiguration.Standard.InMemory())
.ShowSql())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<AdjecentType>())
.ExposeConfiguration(cfg =>
{
var schemaExport = new SchemaExport(cfg);
schemaExport.Execute(true, true, false);
})
.BuildSessionFactory();
@jand187
jand187 / Generic builder with extensions
Last active November 3, 2021 18:14
Generic builder with extensions
public class GenericBuilder<TEntity> where TEntity : new()
{
private readonly List<Func<TEntity, object>> setters;
public GenericBuilder()
{
setters = new List<Func<TEntity, object>>();
}
public GenericBuilder<TEntity> With(params Func<TEntity, object>[] props)