diff options
author | Jérémie Laval <jeremie.laval@gmail.com> | 2011-01-21 18:40:43 +0300 |
---|---|---|
committer | Jérémie Laval <jeremie.laval@gmail.com> | 2011-01-22 04:21:18 +0300 |
commit | 0b04a18b5ceff105987f968c0111df2636e614f4 (patch) | |
tree | 8c0e12735f833cf88a038f622ff481237e387825 /mcs/class/WebMatrix.Data | |
parent | 175bf4428022d2326214de9d15cb23a8c9bd3d97 (diff) |
Add GetLastInsertId
Diffstat (limited to 'mcs/class/WebMatrix.Data')
-rw-r--r-- | mcs/class/WebMatrix.Data/WebMatrix.Data/Database.cs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/mcs/class/WebMatrix.Data/WebMatrix.Data/Database.cs b/mcs/class/WebMatrix.Data/WebMatrix.Data/Database.cs index bef7b74d5e4..71f1be6db31 100644 --- a/mcs/class/WebMatrix.Data/WebMatrix.Data/Database.cs +++ b/mcs/class/WebMatrix.Data/WebMatrix.Data/Database.cs @@ -169,6 +169,14 @@ namespace WebMatrix.Data return result; } + // TODO: I don't think this is actually quite generic (SQL Server specific) + public object GetLastInsertId () + { + const string sql = "select @@IDENTITY"; + + return QueryValue (sql); + } + DbCommand PrepareCommand (string commandText) { var command = connection.CreateCommand (); @@ -179,6 +187,9 @@ namespace WebMatrix.Data static void PrepareCommandParameters (DbCommand command, object[] args) { + if (args.Length == 0) + return; + int index = 0; foreach (var arg in args) { |