diff options
Diffstat (limited to 'mcs/class/WebMatrix.Data')
-rw-r--r-- | mcs/class/WebMatrix.Data/WebMatrix.Data/Database.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/mcs/class/WebMatrix.Data/WebMatrix.Data/Database.cs b/mcs/class/WebMatrix.Data/WebMatrix.Data/Database.cs index c5d52066006..00aacf2b259 100644 --- a/mcs/class/WebMatrix.Data/WebMatrix.Data/Database.cs +++ b/mcs/class/WebMatrix.Data/WebMatrix.Data/Database.cs @@ -39,6 +39,8 @@ namespace WebMatrix.Data { public class Database : IDisposable { + public static event EventHandler<ConnectionEventArgs> ConnectionOpened; + DbConnection connection; private Database (DbConnection connection) @@ -86,7 +88,10 @@ namespace WebMatrix.Data PrepareCommandParameters (command, args); connection.Open (); + TriggerConnectionOpened (this, connection); + var result = command.ExecuteNonQuery (); + connection.Close (); command.Dispose (); @@ -115,6 +120,7 @@ namespace WebMatrix.Data var rows = new List<Dictionary<string, object>> (); connection.Open (); + TriggerConnectionOpened (this, connection); using (var reader = command.ExecuteReader ()) { if (!reader.Read () || !reader.HasRows) @@ -148,7 +154,10 @@ namespace WebMatrix.Data PrepareCommandParameters (command, args); connection.Open (); + TriggerConnectionOpened (this, connection); + var result = command.ExecuteScalar (); + connection.Close (); command.Dispose (); @@ -175,6 +184,13 @@ namespace WebMatrix.Data } } + static TriggerConnectionOpened (Database self, DbConnection connection) + { + EventHandler<ConnectionEventArgs> evt = ConnectionOpened; + if (evt != null) + evt (self, new ConnectionEventArgs (connection)); + } + public DbConnection Connection { get { return connection; |