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.

What is 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. Instead, it interprets method and property names at runtime and maps them to your underlying data-store using a convention-based approach. It does not permit SQL Injection. It was built by Mark Rendle in reaction to Microsoft’s release of Microsoft.Data.dll, taking Ruby’s ActiveRecord and DataMapper gems as its inspiration.

“It’s not an O/RM. It looks a bit like one, but it doesn’t need objects, it doesn’t need a relational database, and it doesn’t need any mapping configuration. So it’s an O/RM without the O or the R or the M. So it’s just a /.”

Let’s take an example

public Album FindAlbumsByTitle(string title)
{
	 return Database.Open().Albums.FindAllByTitle(title);
}

In this example,

Assuming you’re using Simple.Data to access a SQL-based database, the following SQL (or similar depending on your database) is generated along with the requisite boilerplate code to send it to the database and retrieve the resulting data.

SELECT * FROM Albums WHERE Title = @p1

Simple.Data is not limited to SQL databases. The developer community has also built providers to run Simple.Data against several noSQL data stores. For a full listing of the databases currently supported, take a look at the Supported Databases documentation page.

Simple.Data runs on the .NET Framework and Mono.