diff options
author | Gert Driesen <drieseng@users.sourceforge.net> | 2008-12-30 06:41:45 +0300 |
---|---|---|
committer | Gert Driesen <drieseng@users.sourceforge.net> | 2008-12-30 06:41:45 +0300 |
commit | b8ff34617371dfbaac7296843d6ca52ed428b2f9 (patch) | |
tree | f5a8510a07011cc9b82debff267d507dad4fc5a0 /mcs/class/System.Data/System.Data.Common/DbCommandBuilder.cs | |
parent | 9beafa005ea724430f6ae813854eaa8052ae02b7 (diff) |
* DbCommandBuilder.cs: Return a zero-length string when QuotePrefix or
QuoteSuffix are not set (or are set to null). Changing QuotePrefix or
QuoteSuffix after a command has been generated should result in an
InvalidOperationException.
* DbConnectionStringBuilder.cs: Added support for ODBC rules. Major
rewrite fixing many compatibility issues, and improving support for
connectionstring formats/characters.
* System.Data_test.dll.sources: Added OdbcCommandBuilderTest.cs,
OdbcConnectionStringBuilderTest.cs and DbCommandBuilderTest.cs.
* libodbc.cs: Add IdentifierQuoteChar to OdbcInfo.
* OdbcCommandBuilder.cs: Return a zero-length string when QuotePrefix
or QuoteSuffix are not set (or are set to null). Changing QuotePrefix
or QuoteSuffix after a command has been generated should result in an
InvalidOperationException. Implemented support for obtaining
character(s) for quoting identifiers from specified connection.
Modified generated SQL to match MS.
* OdbcConnectionStringBuilder.cs: Improved special casing of Driver
and Dsn keywords. Re-use implemenation of DbConnectionStringBuilder.
Improved argument checks to match MS.
* DbCommandBuilderTest.cs: Added tests for QuotePrefix and
QuoteSuffix.
* DbConnectionStringBuilderTest.cs: Added tests for both odbc and
non-odbc rules.
* OdbcCommandBuilderTest.cs: Added tests for QuotePrefix and
QuoteSuffix. Added tests for QuoteIdentifier (some still marked
NotWorking).
* OdbcConnectionStringBuilderTest.cs: Moved from ProviderTests.
Added and improved tests.
svn path=/trunk/mcs/; revision=122225
Diffstat (limited to 'mcs/class/System.Data/System.Data.Common/DbCommandBuilder.cs')
-rw-r--r-- | mcs/class/System.Data/System.Data.Common/DbCommandBuilder.cs | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/mcs/class/System.Data/System.Data.Common/DbCommandBuilder.cs b/mcs/class/System.Data/System.Data.Common/DbCommandBuilder.cs index 3ea15d68650..57815b7f588 100644 --- a/mcs/class/System.Data/System.Data.Common/DbCommandBuilder.cs +++ b/mcs/class/System.Data/System.Data.Common/DbCommandBuilder.cs @@ -100,13 +100,23 @@ namespace System.Data.Common { get { return GetQuotedString (_tableName); } } + bool IsCommandGenerated { + get { + return (_insertCommand != null || _updateCommand != null || _deleteCommand != null); + } + } + private string GetQuotedString (string value) { if (value == String.Empty || value == null) return value; - if (_quotePrefix == String.Empty && _quoteSuffix == String.Empty) + + string prefix = QuotePrefix; + string suffix = QuoteSuffix; + + if (prefix.Length == 0 && suffix.Length == 0) return value; - return String.Format ("{0}{1}{2}", _quotePrefix, value, _quoteSuffix); + return String.Format ("{0}{1}{2}", prefix, value, suffix); } private void BuildInformation (DataTable schemaTable) @@ -407,14 +417,36 @@ namespace System.Data.Common { [DefaultValue ("")] public virtual string QuotePrefix { - get { return _quotePrefix; } - set { if (value != null) _quotePrefix = value; } + get { + if (_quotePrefix == null) + return string.Empty; + return _quotePrefix; + } + set { + if (IsCommandGenerated) + throw new InvalidOperationException ( + "QuotePrefix cannot be set after " + + "an Insert, Update or Delete command " + + "has been generated."); + _quotePrefix = value; + } } [DefaultValue ("")] public virtual string QuoteSuffix { - get { return _quoteSuffix; } - set { if (value != null) _quoteSuffix = value; } + get { + if (_quoteSuffix == null) + return string.Empty; + return _quoteSuffix; + } + set { + if (IsCommandGenerated) + throw new InvalidOperationException ( + "QuoteSuffix cannot be set after " + + "an Insert, Update or Delete command " + + "has been generated."); + _quoteSuffix = value; + } } [DefaultValue (".")] |