Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Laval <jeremie.laval@gmail.com>2011-01-21 18:26:57 +0300
committerJérémie Laval <jeremie.laval@gmail.com>2011-01-22 04:21:16 +0300
commit408b7c2c49369a43423272a739a8e3ffff5447af (patch)
tree994276c7b2c3256d04e9168ad94bb390df04c6b1 /mcs/class/WebMatrix.Data
parentb4b7fbbd379b6a32d12f1d71c804caeae3078618 (diff)
Add ConnectionOpened event to Database
Diffstat (limited to 'mcs/class/WebMatrix.Data')
-rw-r--r--mcs/class/WebMatrix.Data/WebMatrix.Data/Database.cs16
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;