Simple.Data

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, reactjs development services 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 /.”

Simple.Data

Let’s take an example

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

In this example,

  • Database.Open() is dynamic and has no pre-defined Albums property.
  • Albums is returned as a DynamicTable, which is also dynamic. It has no pre-defined FindAllByTitle() method.
  • When Simple.Data sees a call to a FindAllBy*() method, it pulls apart the rest of the method name, combines it with the arguments and builds an ADO.NET command which safely encapsulates the name and password values inside parameters.

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.

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

Other resources: Adding and modification of data in a data store