Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DatabaseFactory class for Simple.Data + Impromptu
static class DatabaseFactory
{
public static IDatabase Create()
{
Database.UseMockAdapter(CreateMockAdapter());
// This single line of code applies all these interfaces
return Impromptu.ActLike<IDatabase>(Database.Open());
}
private static InMemoryAdapter CreateMockAdapter()
{
var inmem = new InMemoryAdapter(StringComparer.OrdinalIgnoreCase);
inmem.SetAutoIncrementKeyColumn("Customers", "Id");
inmem.SetAutoIncrementKeyColumn("Employees", "Id");
inmem.Join.Master("Customers", "Id", "Employees").Detail("Employees", "EmployerId", "Employer");
return inmem;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.