[ADOAdapter Only]
Simple.Data’s aggressive attitude to closing database connections may not be optimal for you, but it is possible to
SqlConnection
)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); conn.Open(); db.UseSharedConnection(conn); 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); db.StopUsingSharedConnection(); conn.Close();