Author: anagappan
Date: 2007-07-22 03:09:26 -0400 (Sun, 22 Jul 2007)
New Revision: 82428
Modified:
trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopy.cs
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopyColumnMapping.cs
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopyColumnMappingCollection.cs
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopyOptions.cs
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlClientPermission.cs
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlException.cs
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlParameter.cs
Log:
2007-07-22 Nagappan A <[EMAIL PROTECTED]>
* SqlBulkCopy.cs (NotifyAfter): Implemented 2.0 property.
(GetColumnMetaData, GenerateColumnMetaData):
(ValidateColumnMapping): Implemented private method's to generate
and validate SqlBulkCopy headers.
(BulkCopyToServer): Private method to actually do the bulk copy
processing.
(WriteToServer): Implemented 2.0 missing overloaded methods.
(IDisposable.Dispose): Implemented 2.0 missing method.
* SqlBulkCopyColumnMappingCollection.cs (Add, CopyTo): Implemented
missing API.
(Item): Implemented missing property.
* SqlBulkCopyColumnMapping.cs: Modified the implementation of
Constructors to use property.
* SqlDataReader.cs (GetSqlXml, IsCommandBehaviour): Added 2.0
missing method.
(Connection): Added missing property.
* SqlParameter.cs (SetSqlDbType, ConvertToFrameworkType): Modified
method as internal from private.
* SqlConnection.cs: Fixed 2.0 missing feature.
* SqlException.cs: Fixed 2.0 missing feature.
* SqlClientPermission.cs: Fixed 2.0 missing feature.
Modified: trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog 2007-07-22
06:57:28 UTC (rev 82427)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/ChangeLog 2007-07-22
07:09:26 UTC (rev 82428)
@@ -1,3 +1,34 @@
+2007-07-22 Nagappan A <[EMAIL PROTECTED]>
+
+ * SqlBulkCopy.cs (NotifyAfter): Implemented 2.0 property.
+ (GetColumnMetaData, GenerateColumnMetaData):
+ (ValidateColumnMapping): Implemented private method's to generate
+ and validate SqlBulkCopy headers.
+ (BulkCopyToServer): Private method to actually do the bulk copy
+ processing.
+ (WriteToServer): Implemented 2.0 missing overloaded methods.
+ (IDisposable.Dispose): Implemented 2.0 missing method.
+
+ * SqlBulkCopyColumnMappingCollection.cs (Add, CopyTo): Implemented
+ missing API.
+ (Item): Implemented missing property.
+
+ * SqlBulkCopyColumnMapping.cs: Modified the implementation of
+ Constructors to use property.
+
+ * SqlDataReader.cs (GetSqlXml, IsCommandBehaviour): Added 2.0
+ missing method.
+ (Connection): Added missing property.
+
+ * SqlParameter.cs (SetSqlDbType, ConvertToFrameworkType): Modified
+ method as internal from private.
+
+ * SqlConnection.cs: Fixed 2.0 missing feature.
+
+ * SqlException.cs: Fixed 2.0 missing feature.
+
+ * SqlClientPermission.cs: Fixed 2.0 missing feature.
+
2007-07-01 Gert Driesen <[EMAIL PROTECTED]>
* ISqlNotificationReceiver.cs: Removed.
Modified: trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopy.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopy.cs
2007-07-22 06:57:28 UTC (rev 82427)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopy.cs
2007-07-22 07:09:26 UTC (rev 82428)
@@ -33,6 +33,8 @@
using System;
using System.Data;
using System.Data.Common;
+using Mono.Data.Tds;
+using Mono.Data.Tds.Protocol;
namespace System.Data.SqlClient {
public sealed class SqlBulkCopy : IDisposable
@@ -40,34 +42,45 @@
#region Fields
private int _batchSize = 0;
+ private int _notifyAfter = 0;
private int _bulkCopyTimeout = 0;
private SqlBulkCopyColumnMappingCollection
_columnMappingCollection = new SqlBulkCopyColumnMappingCollection ();
private string _destinationTableName = null;
+ private bool ordinalMapping = false;
+ bool sqlRowsCopied = false;
+ bool identityInsert = false;
+ bool isLocalConnection = false;
+ SqlConnection connection;
+ SqlBulkCopyOptions copyOptions = SqlBulkCopyOptions.Default;
#endregion
#region Constructors
- [MonoTODO]
public SqlBulkCopy (SqlConnection connection)
{
- throw new NotImplementedException ();
+ this.connection = connection;
}
- [MonoTODO]
public SqlBulkCopy (string connectionString)
{
- throw new NotImplementedException ();
+ this.connection = new SqlConnection (connectionString);
+ isLocalConnection = true;
}
[MonoTODO]
public SqlBulkCopy (string connectionString, SqlBulkCopyOptions
copyOptions)
{
+ this.connection = new SqlConnection (connectionString);
+ this.copyOptions = copyOptions;
+ isLocalConnection = true;
throw new NotImplementedException ();
}
[MonoTODO]
public SqlBulkCopy (SqlConnection connection,
SqlBulkCopyOptions copyOptions, SqlTransaction externalTransaction)
{
+ this.connection = connection;
+ this.copyOptions = copyOptions;
throw new NotImplementedException ();
}
@@ -89,53 +102,372 @@
get { return _columnMappingCollection; }
}
- [MonoTODO]
public string DestinationTableName {
- // FIXME: Related to WriteToServer
get { return _destinationTableName; }
set { _destinationTableName = value; }
}
+ public int NotifyAfter {
+ get { return _notifyAfter; }
+ set {
+ if (value < 0)
+ throw new ArgumentOutOfRangeException
("NotifyAfter should be greater than or equal to 0");
+ _notifyAfter = value;
+ }
+ }
+
#endregion
#region Methods
- [MonoTODO]
public void Close ()
{
- throw new NotImplementedException ();
+ if (sqlRowsCopied == true) {
+ throw new InvalidOperationException ("Close
should not be called from SqlRowsCopied event");
+ }
+ if (connection == null || connection.State ==
ConnectionState.Closed) {
+ return;
+ }
+ connection.Close ();
}
- [MonoTODO]
+ private DataTable [] GetColumnMetaData ()
+ {
+ DataTable [] columnMetaDataTables = new DataTable [2];
+ SqlCommand cmd = new SqlCommand ("select @@trancount; "
+
+ "set fmtonly on select
* from " +
+ DestinationTableName +
" set fmtonly off;" +
+ "exec
sp_tablecollations_90 '" +
+ DestinationTableName +
"'",
+ connection);
+ SqlDataReader reader = cmd.ExecuteReader ();
+ int i = 0; // Skipping 1st result
+ do {
+ if (i == 1) {
+ columnMetaDataTables [i - 1] =
reader.GetSchemaTable ();
+ } else if (i == 2) {
+ SqlDataAdapter adapter = new
SqlDataAdapter ();
+ adapter.MissingSchemaAction =
MissingSchemaAction.AddWithKey;
+ columnMetaDataTables [i - 1] = new
DataTable ();
+ adapter.FillInternal
(columnMetaDataTables [i - 1], reader);
+ }
+ i++;
+ } while (reader.IsClosed == false &&
reader.NextResult());
+ reader.Close ();
+ return columnMetaDataTables;
+ }
+
+ private string GenerateColumnMetaData (SqlCommand tmpCmd,
DataTable colMetaData, DataTable tableCollations)
+ {
+ bool flag = false;
+ string statement = "";
+ int i = 0;
+ foreach (DataRow row in colMetaData.Rows) {
+ flag = false;
+ foreach (DataColumn col in colMetaData.Columns)
{ // FIXME: This line not required, remove later
+ object value = null;
+ if (_columnMappingCollection.Count > 0)
{
+ if (ordinalMapping) {
+ foreach
(SqlBulkCopyColumnMapping mapping
+ in
_columnMappingCollection) {
+ if
(mapping.DestinationOrdinal == i) {
+ flag =
true;
+ break;
+ }
+ }
+ } else {
+ foreach
(SqlBulkCopyColumnMapping mapping
+ in
_columnMappingCollection) {
+ if
(mapping.DestinationColumn == (string) row ["ColumnName"]) {
+ flag =
true;
+ break;
+ }
+ }
+ }
+ if (flag == false)
+ break;
+ }
+ if ((bool)row ["IsReadOnly"]) {
+ if (ordinalMapping)
+ value = false;
+ else
+ break;
+ }
+ SqlParameter param = new SqlParameter
((string) row ["ColumnName"],
+
((SqlDbType) row ["ProviderType"]));
+ param.Value = value;
+ if ((int)row ["ColumnSize"] != -1) {
+ param.Size = (int) row
["ColumnSize"];
+ }
+ tmpCmd.Parameters.Add (param);
+ break;
+ }
+ i++;
+ }
+ flag = false;
+ bool insertSt = false;
+ foreach (DataRow row in colMetaData.Rows) {
+ if (_columnMappingCollection.Count > 0) {
+ i = 0;
+ insertSt = false;
+ foreach (SqlParameter param in
tmpCmd.Parameters) {
+ if (ordinalMapping) {
+ foreach
(SqlBulkCopyColumnMapping mapping
+ in
_columnMappingCollection) {
+ if
(mapping.DestinationOrdinal == i && param.Value == null) {
+
insertSt = true;
+ }
+ }
+ } else {
+ foreach
(SqlBulkCopyColumnMapping mapping
+ in
_columnMappingCollection) {
+ if
(mapping.DestinationColumn == param.ParameterName &&
+ (string)row
["ColumnName"] == param.ParameterName) {
+
insertSt = true;
+
param.Value = null;
+ }
+ }
+ }
+ i++;
+ if (insertSt == true)
+ break;
+ }
+ if (insertSt == false)
+ continue;
+ }
+ if ((bool)row ["IsReadOnly"]) {
+ continue;
+ }
+ string columnInfo = "";
+ if ((int)row ["ColumnSize"] != -1) {
+ columnInfo = string.Format ("{0}({1})",
+ (SqlDbType)
row ["ProviderType"],
+ row
["ColumnSize"]);
+ } else {
+ columnInfo = string.Format ("{0}",
(SqlDbType) row ["ProviderType"]);
+ }
+ if (flag)
+ statement += ", ";
+ string columnName = (string) row ["ColumnName"];
+ statement += string.Format ("[{0}] {1}",
columnName, columnInfo);
+ if (flag == false)
+ flag = true;
+ if (tableCollations != null) {
+ foreach (DataRow collationRow in
tableCollations.Rows) {
+ if ((string)collationRow
["name"] == columnName) {
+ statement +=
string.Format (" COLLATE {0}", collationRow ["collation"]);
+ break;
+ }
+ }
+ }
+ }
+ return statement;
+ }
+
+ private void ValidateColumnMapping (DataTable table, DataTable
tableCollations)
+ {
+ foreach (SqlBulkCopyColumnMapping _columnMapping in
_columnMappingCollection) {
+ if (ordinalMapping == false &&
+ (_columnMapping.DestinationColumn ==
String.Empty ||
+ _columnMapping.SourceColumn ==
String.Empty))
+ throw new InvalidOperationException
("Mappings must be either all null or ordinal");
+ if (ordinalMapping &&
+ (_columnMapping.DestinationOrdinal == -1 ||
+ _columnMapping.SourceOrdinal == -1))
+ throw new InvalidOperationException
("Mappings must be either all null or ordinal");
+ bool flag = false;
+ if (ordinalMapping == false) {
+ foreach (DataRow row in
tableCollations.Rows) {
+ if ((string)row ["name"] ==
_columnMapping.DestinationColumn) {
+ flag = true;
+ break;
+ }
+ }
+ if (flag == false)
+ throw new
InvalidOperationException ("ColumnMapping does not match");
+ flag = false;
+ foreach (DataColumn col in
table.Columns) {
+ if (col.ColumnName ==
_columnMapping.SourceColumn) {
+ flag = true;
+ break;
+ }
+ }
+ if (flag == false)
+ throw new
InvalidOperationException ("ColumnName " +
+
_columnMapping.SourceColumn +
+
" does not match");
+ } else {
+ if (_columnMapping.DestinationOrdinal
>= tableCollations.Rows.Count)
+ throw new
InvalidOperationException ("ColumnMapping does not match");
+ }
+ }
+ }
+
+ private void BulkCopyToServer (DataTable table, DataRowState
state)
+ {
+ if (connection == null || connection.State ==
ConnectionState.Closed)
+ throw new InvalidOperationException ("This
method should not be called on a closed connection");
+ if (_destinationTableName == null)
+ throw new ArgumentNullException
("DestinationTableName");
+ if (identityInsert) {
+ SqlCommand cmd = new SqlCommand ("set
identity_insert " +
+
table.TableName + " on",
+ connection);
+ cmd.ExecuteScalar ();
+ }
+ DataTable [] columnMetaDataTables = GetColumnMetaData
();
+ DataTable colMetaData = columnMetaDataTables [0];
+ DataTable tableCollations = columnMetaDataTables [1];
+
+ if (_columnMappingCollection.Count > 0) {
+ if (_columnMappingCollection [0].SourceOrdinal
!= -1)
+ ordinalMapping = true;
+ ValidateColumnMapping (table, tableCollations);
+ }
+
+ SqlCommand tmpCmd = new SqlCommand ();
+ TdsBulkCopy blkCopy = new TdsBulkCopy
((Tds)connection.Tds);
+ if (((Tds)connection.Tds).TdsVersion >=
TdsVersion.tds70) {
+ string statement = "insert bulk " +
DestinationTableName + " (";
+ statement += GenerateColumnMetaData (tmpCmd,
colMetaData, tableCollations);
+ statement += ")";
+ blkCopy.SendColumnMetaData (statement);
+ }
+ blkCopy.BulkCopyStart
(tmpCmd.Parameters.MetaParameters);
+ foreach (DataRow row in table.Rows) {
+ if (row.RowState == DataRowState.Deleted)
+ continue; // Don't copy the row that's
in deleted state
+ if (state != 0 && row.RowState != state)
+ continue;
+ bool isNewRow = true;
+ int i = 0;
+ foreach (SqlParameter param in
tmpCmd.Parameters) {
+ int size = 0;
+ object rowToCopy = null;
+ if (_columnMappingCollection.Count > 0)
{
+ if (ordinalMapping) {
+ foreach
(SqlBulkCopyColumnMapping mapping
+ in
_columnMappingCollection) {
+ if
(mapping.DestinationOrdinal == i && param.Value == null) {
+
rowToCopy = row [mapping.SourceOrdinal];
+
SqlParameter parameter = new SqlParameter (mapping.SourceOrdinal.ToString (),
+
rowToCopy);
+ if
(param.MetaParameter.TypeName != parameter.MetaParameter.TypeName) {
+
parameter.SqlDbType = param.SqlDbType;
+
rowToCopy = parameter.Value = parameter.ConvertToFrameworkType (rowToCopy);
+ }
+ string
colType = string.Format ("{0}", parameter.MetaParameter.TypeName);
+ if
(colType == "nvarchar") {
+
if (row [i] != null) {
+
size = ((string) parameter.Value).Length;
+
size <<= 1;
+
}
+ } else {
+
size = parameter.Size;
+ }
+ break;
+ }
+ }
+ } else {
+ foreach
(SqlBulkCopyColumnMapping mapping
+ in
_columnMappingCollection) {
+ if
(mapping.DestinationColumn == param.ParameterName) {
+
rowToCopy = row [mapping.SourceColumn];
+
SqlParameter parameter = new SqlParameter (mapping.SourceColumn, rowToCopy);
+ if
(param.MetaParameter.TypeName != parameter.MetaParameter.TypeName) {
+
parameter.SqlDbType = param.SqlDbType;
+
rowToCopy = parameter.Value = parameter.ConvertToFrameworkType (rowToCopy);
+ }
+ string
colType = string.Format ("{0}", parameter.MetaParameter.TypeName);
+ if
(colType == "nvarchar") {
+
if (row [mapping.SourceColumn] != null) {
+
size = ((string) rowToCopy).Length;
+
size <<= 1;
+
}
+ } else {
+
size = parameter.Size;
+ }
+ break;
+ }
+ }
+ }
+ i++;
+ } else {
+ rowToCopy = row
[param.ParameterName];
+ string colType =
param.MetaParameter.TypeName;
+ /*
+ If column type is
SqlDbType.NVarChar the size of parameter is multiplied by 2
+ FIXME: Need to check for
other types
+ */
+ if (colType == "nvarchar") {
+ size = ((string) row
[param.ParameterName]).Length;
+ size <<= 1;
+ } else {
+ size = param.Size;
+ }
+ }
+ if (rowToCopy == null)
+ continue;
+ blkCopy.BulkCopyData (rowToCopy, size,
isNewRow);
+ if (isNewRow)
+ isNewRow = false;
+ }
+ }
+ blkCopy.BulkCopyEnd ();
+ }
+
public void WriteToServer (DataRow [] rows)
{
- throw new NotImplementedException ();
+ if (rows == null)
+ throw new ArgumentNullException ("rows");
+ DataTable table = new DataTable (rows
[0].Table.TableName);
+ foreach (DataColumn col in rows [0].Table.Columns) {
+ DataColumn tmpCol = new DataColumn
(col.ColumnName, col.DataType);
+ table.Columns.Add (tmpCol);
+ }
+ foreach (DataRow row in rows) {
+ DataRow tmpRow = table.NewRow ();
+ for (int i = 0; i < table.Columns.Count; i++) {
+ tmpRow [i] = row [i];
+ }
+ table.Rows.Add (tmpRow);
+ }
+ BulkCopyToServer (table, 0);
}
- [MonoTODO]
public void WriteToServer (DataTable table)
{
- throw new NotImplementedException ();
+ BulkCopyToServer (table, 0);
}
- [MonoTODO]
public void WriteToServer (IDataReader reader)
{
- throw new NotImplementedException ();
+ DataTable table = new DataTable ();
+ SqlDataAdapter adapter = new SqlDataAdapter ();
+ adapter.FillInternal (table, reader);
+ BulkCopyToServer (table, 0);
}
- [MonoTODO]
public void WriteToServer (DataTable table, DataRowState
rowState)
{
- throw new NotImplementedException ();
+ BulkCopyToServer (table, rowState);
}
#endregion
- [MonoTODO]
+ #region Events
+
+ public event SqlRowsCopiedEventHandler SqlRoswCopied;
+
+ #endregion
+
void IDisposable.Dispose ()
{
- throw new NotImplementedException ();
+ //throw new NotImplementedException ();
+ if (isLocalConnection) {
+ Close ();
+ connection = null;
+ }
}
}
Modified:
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopyColumnMapping.cs
===================================================================
---
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopyColumnMapping.cs
2007-07-22 06:57:28 UTC (rev 82427)
+++
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopyColumnMapping.cs
2007-07-22 07:09:26 UTC (rev 82428)
@@ -29,7 +29,6 @@
//
#if NET_2_0
-
namespace System.Data.SqlClient
{
/// <summary>
@@ -41,8 +40,8 @@
#region Fields
- int sourceOrdinal = 0;
- int destinationOrdinal = 0;
+ int sourceOrdinal = -1;
+ int destinationOrdinal = -1;
string sourceColumn = null;
string destinationColumn = null;
@@ -50,28 +49,27 @@
#region Constructors
- public SqlBulkCopyColumnMapping(){
-
+ public SqlBulkCopyColumnMapping() {
}
public SqlBulkCopyColumnMapping(int sourceColumnOrdinal, int
destinationOrdinal){
- this.sourceOrdinal = sourceColumnOrdinal;
- this.destinationOrdinal = destinationOrdinal;
+ SourceOrdinal = sourceColumnOrdinal;
+ DestinationOrdinal = destinationOrdinal;
}
public SqlBulkCopyColumnMapping(int sourceColumnOrdinal, string
destinationColumn){
- this.sourceOrdinal = sourceColumnOrdinal;
- this.destinationColumn = destinationColumn;
+ SourceOrdinal = sourceColumnOrdinal;
+ DestinationColumn = destinationColumn;
}
public SqlBulkCopyColumnMapping(string sourceColumn, int
destinationOrdinal){
- this.sourceColumn = sourceColumn;
- this.destinationOrdinal = destinationOrdinal;
+ SourceColumn = sourceColumn;
+ DestinationOrdinal = destinationOrdinal;
}
public SqlBulkCopyColumnMapping(string sourceColumn, string
destinationColumn){
- this.sourceColumn = sourceColumn;
- this.destinationColumn = destinationColumn;
+ SourceColumn = sourceColumn;
+ DestinationColumn = destinationColumn;
}
# endregion //Constructors
@@ -104,10 +102,8 @@
this.sourceOrdinal = -1;
this.sourceColumn = value;
}
-
}
-
public int DestinationOrdinal {
get {
return this.destinationOrdinal;
@@ -115,11 +111,10 @@
set {
// ms: whenever the ordinal is set, the name is null
if (value < 0)
- throw new ArgumentOutOfRangeException();
+ throw new IndexOutOfRangeException ();
this.destinationColumn = null;
this.destinationOrdinal = value;
}
-
}
public int SourceOrdinal {
@@ -129,19 +124,15 @@
set {
// ms: whenever the ordinal is set, the name is null
if (value < 0)
- throw new ArgumentOutOfRangeException();
+ throw new IndexOutOfRangeException ();
this.sourceColumn = null;
this.sourceOrdinal = value;
}
-
}
#endregion //Properties
-
- }
+ }
}
-
#endif
-
Modified:
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopyColumnMappingCollection.cs
===================================================================
---
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopyColumnMappingCollection.cs
2007-07-22 06:57:28 UTC (rev 82427)
+++
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopyColumnMappingCollection.cs
2007-07-22 07:09:26 UTC (rev 82428)
@@ -39,41 +39,56 @@
{
public sealed class SqlBulkCopyColumnMappingCollection : CollectionBase
{
+ public SqlBulkCopyColumnMapping this [int value] {
+ get {
+ if (value < 0 || value > base.Count)
+ throw new ArgumentOutOfRangeException
("Index is out of range");
+ return (SqlBulkCopyColumnMapping) base.List
[value];
+ }
+ }
+
#region Methods
- [MonoTODO]
public SqlBulkCopyColumnMapping Add (SqlBulkCopyColumnMapping
bulkCopyColumnMapping)
{
- throw new NotImplementedException ();
+ if (bulkCopyColumnMapping == null)
+ throw new ArgumentNullException
("bulkCopyColumnMapping");
+ List.Add (bulkCopyColumnMapping);
+ return bulkCopyColumnMapping;
+
}
- [MonoTODO]
public SqlBulkCopyColumnMapping Add (int sourceColumnIndex, int
destinationColumnIndex)
{
- throw new NotImplementedException ();
+ SqlBulkCopyColumnMapping columnMapping = new
SqlBulkCopyColumnMapping (sourceColumnIndex,
+
destinationColumnIndex);
+ return Add (columnMapping);
}
- [MonoTODO]
public SqlBulkCopyColumnMapping Add (int sourceColumnIndex,
string destinationColumn)
{
- throw new NotImplementedException ();
+ SqlBulkCopyColumnMapping columnMapping = new
SqlBulkCopyColumnMapping (sourceColumnIndex,
+
destinationColumn);
+ return Add (columnMapping);
}
- [MonoTODO]
public SqlBulkCopyColumnMapping Add (string sourceColumn, int
destinationColumnIndex)
{
- throw new NotImplementedException ();
+ SqlBulkCopyColumnMapping columnMapping = new
SqlBulkCopyColumnMapping (sourceColumn,
+
destinationColumnIndex);
+ return Add (columnMapping);
}
- [MonoTODO]
public SqlBulkCopyColumnMapping Add (string sourceColumn,
string destinationColumn)
{
- throw new NotImplementedException ();
+ SqlBulkCopyColumnMapping columnMapping = new
SqlBulkCopyColumnMapping (sourceColumn,
+
destinationColumn);
+ return Add (columnMapping);
}
public new void Clear ()
{
- throw new NotImplementedException ();
+ List.Clear ();
}
public bool Contains (SqlBulkCopyColumnMapping value)
@@ -86,6 +101,19 @@
return List.IndexOf (value);
}
+ public void CopyTo (SqlBulkCopyColumnMapping [] array, int
index)
+ {
+ if (index < 0 || index > base.Count)
+ throw new ArgumentOutOfRangeException ("Index
is out of range");
+ if (array == null)
+ throw new ArgumentNullException ("array");
+ int len = base.Count;
+ if (len - index > array.Length)
+ len = array.Length;
+ for (int i = index, j = 0; i < base.Count; i++, j++)
+ array [j] = (SqlBulkCopyColumnMapping) List [i];
+ }
+
public void Insert (int index, SqlBulkCopyColumnMapping value)
{
if (index < 0 || index > base.Count)
@@ -98,12 +126,10 @@
List.Remove (value);
}
- [MonoTODO]
public new void RemoveAt (int index)
{
if (index < 0 || index > base.Count)
throw new ArgumentOutOfRangeException ("Index
is out of range");
- // FIXME: Implement WriteToServer
base.RemoveAt (index);
}
Modified:
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopyOptions.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopyOptions.cs
2007-07-22 06:57:28 UTC (rev 82427)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/SqlBulkCopyOptions.cs
2007-07-22 07:09:26 UTC (rev 82428)
@@ -47,9 +47,7 @@
TableLock = 4,
UseInternalTransaction = 32
}
-
}
-
#endif
Modified:
trunk/mcs/class/System.Data/System.Data.SqlClient/SqlClientPermission.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/SqlClientPermission.cs
2007-07-22 06:57:28 UTC (rev 82427)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/SqlClientPermission.cs
2007-07-22 07:09:26 UTC (rev 82428)
@@ -85,8 +85,7 @@
return new SqlClientPermission (this);
}
-#if ONLY_1_1
- [MonoTODO ("overridden for what ? additional validations ???")]
+#if NET_1_1
public override void Add (string connectionString, string
restrictions, KeyRestrictionBehavior behavior)
{
base.Add (connectionString, restrictions, behavior);
Modified: trunk/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs
2007-07-22 06:57:28 UTC (rev 82427)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs
2007-07-22 07:09:26 UTC (rev 82428)
@@ -505,7 +505,7 @@
if (Connection.Tds.NextResult () &&
Connection.Tds.NextRow ())
result = Connection.Tds.ColumnValues[0];
-
+
if (commandType == CommandType.StoredProcedure)
{
Connection.Tds.SkipToEnd ();
GetOutputParameters ();
Modified: trunk/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs
2007-07-22 06:57:28 UTC (rev 82427)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs
2007-07-22 07:09:26 UTC (rev 82428)
@@ -125,12 +125,16 @@
#region Properties
-#if !NET_2_0
+#if NET_1_0 || ONLY_1_1
[DataSysDescription ("Information used to connect to a
DataSource, such as 'Data Source=x;Initial Catalog=x;Integrated
Security=SSPI'.")]
#endif
[DefaultValue ("")]
[EditorAttribute
("Microsoft.VSDesigner.Data.SQL.Design.SqlConnectionStringEditor, "+
Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+
Consts.AssemblySystem_Drawing )]
+#if NET_2_0
+ [SettingsBindableAttribute (true)]
+#else
[RecommendedAsConfigurable (true)]
+#endif
[RefreshProperties (RefreshProperties.All)]
[MonoTODO("persist security info, encrypt, enlist keyword not
implemented")]
public
Modified: trunk/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs
2007-07-22 06:57:28 UTC (rev 82427)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs
2007-07-22 07:09:26 UTC (rev 82428)
@@ -162,6 +162,14 @@
public override int VisibleFieldCount {
get { return visibleFieldCount; }
}
+
+ protected SqlConnection Connection {
+ get { return command.Connection; }
+ }
+
+ protected bool IsCommandBehaviour (CommandBehavior condition) {
+ return condition == command.CommandBehavior;
+ }
#endif
#endregion // Properties
@@ -219,7 +227,7 @@
return schemaTable;
}
#if NET_2_0
- protected override
+ protected new
#endif
void Dispose (bool disposing)
{
@@ -931,6 +939,19 @@
return (SqlString) value;
}
+#if NET_2_0
+ [EditorBrowsableAttribute (EditorBrowsableState.Never)]
+ public virtual SqlXml GetSqlXml (int i)
+ {
+ object value = GetSqlValue (i);
+ if (!(value is SqlXml)) {
+ if (value is DBNull) throw new
SqlNullValueException ();
+ throw new InvalidCastException ("Type is " +
value.GetType ().ToString ());
+ }
+ return (SqlXml) value;
+ }
+#endif // NET_2_0
+
public
#if NET_2_0
virtual
@@ -1005,6 +1026,12 @@
if (value == DBNull.Value)
return SqlByte.Null;
return (SqlByte) ((byte) value);
+#if NET_2_0
+ case SqlDbType.Xml:
+ if (value == DBNull.Value)
+ return SqlByte.Null;
+ return (SqlXml) value;
+#endif
}
throw new InvalidOperationException ("The type of this
column is unknown.");
Modified: trunk/mcs/class/System.Data/System.Data.SqlClient/SqlException.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/SqlException.cs
2007-07-22 06:57:28 UTC (rev 82427)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/SqlException.cs
2007-07-22 07:09:26 UTC (rev 82428)
@@ -109,7 +109,13 @@
get { return Errors [0].LineNumber; }
}
- public override string Message {
+ public
+#if NET_1_0 || NET_1_1
+ override
+#else
+ new
+#endif
+ string Message {
get {
if (Errors.Count == 0)
return base.Message;
Modified: trunk/mcs/class/System.Data/System.Data.SqlClient/SqlParameter.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.SqlClient/SqlParameter.cs
2007-07-22 06:57:28 UTC (rev 82427)
+++ trunk/mcs/class/System.Data/System.Data.SqlClient/SqlParameter.cs
2007-07-22 07:09:26 UTC (rev 82428)
@@ -702,7 +702,7 @@
// When the SqlDbType is set, we also set the DbType, as well
as the SQL Server
// string representation of the type name. If the SqlDbType is
not convertible
// to a DbType, throw an exception.
- private void SetSqlDbType (SqlDbType type)
+ internal void SetSqlDbType (SqlDbType type)
{
string exception = String.Format ("No mapping exists
from SqlDbType {0} to a known DbType.", type);
@@ -860,7 +860,7 @@
return value;
}
- private object ConvertToFrameworkType (object value)
+ internal object ConvertToFrameworkType (object value)
{
if (value == null || value == DBNull.Value)
return value;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches