Simple.Data

Simple.Data is a lightweight framework that uses the dynamic features of .NET 4 to provide an expressive, ORM-ish way of accessing and manipulating data without any of the code pre-generation and boilerplate required by other frameworks. In this section, we see why and how to get started with Simple.Data.

Configuration

Once you’ve downloaded the required Simple.Data assemblies, you have the option to store your data store’s connection details in your program’s configuration file. Simple.Data looks for no other information from this file.

You have two options for storing a Simple.Data connection string in a config file.

Use the default connection string name.

<configuration>
  <connectionStrings>
    <add name="Simple.Data.Properties.Settings.DefaultConnectionString"
        connectionString="--Your connection string--" />
  </connectionStrings>
</configuration>

Then you can open this database with the parameterless Open() method:

var db = Database.Open();

Store it as a named connection string

<configuration>
  <connectionStrings>
    <add name="MvcMusicStoreDB"
        connectionString="--Your connection string" />
  </connectionStrings>
</configuration>

Then you can open this database with the OpenNamedConnection() method:

var db = Database.OpenNamedConnection("MvcMusicStoreDB");