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.

Using a Shared Connection

[ADOAdapter Only]

Simple.Data’s aggressive attitude to closing database connections may not be optimal for you, but it is possible to

The Simple.Data.Ado adaptor includes the UseSharedConnection() and StopUsingSharedConnection() methods for this purpose

public readonly string MagicConnection = "--Your connection string--";
var db = Database.OpenConnection(MagicConnection);
SqlConnection conn = new SqlConnection(MagicConnection);

var artist = db.Artists.FindByName("Aerosmith");
Console.WriteLine("Id: {0}, Name: {1}", artist.ArtistId, artist.Name);

var artist2 = db.Artists.FindByName("Metallica");
Console.WriteLine("Id: {0}, Name: {1}", artist2.ArtistId, artist2.Name);

var artist3 = db.Artists.FindByName("Iron Maiden");
Console.WriteLine("Id: {0}, Name: {1}", artist3.ArtistId, artist3.Name);