[Mono-list] Re: [PATCH] Patch for SqlCommandBuilder and two questions about SqlCommandBuilder
class.
Carlos Guzmán Álvarez
carlosga@telefonica.net
Tue, 10 Dec 2002 10:41:19 +0100
This is a multi-part message in MIME format.
--------------080102040000090508030003
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Hello:
The patch file :P
Best regards
Carlos Guzmán Álvarez
Vigo-Spain
--------------080102040000090508030003
Content-Type: text/plain;
name="SqlCommandBuilderPatch.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="SqlCommandBuilderPatch.txt"
Index: SqlCommandBuilder.cs
===================================================================
RCS file: /mono/mcs/class/System.Data/System.Data.SqlClient/SqlCommandBuilder.cs,v
retrieving revision 1.7
diff -u -r1.7 SqlCommandBuilder.cs
--- SqlCommandBuilder.cs 13 Nov 2002 17:32:22 -0000 1.7
+++ SqlCommandBuilder.cs 10 Dec 2002 09:34:06 -0000
@@ -174,7 +174,21 @@
if (!isKey) {
parameter = deleteCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow));
- dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
+ if(tableMapping != null)
+ {
+ if(tableMapping.ColumnMappings.Count > 0)
+ {
+ dsColumnName = tableMapping.ColumnMappings[parameter.SourceColumn].DataSetColumn;
+ }
+ else
+ {
+ dsColumnName = parameter.SourceColumn;
+ }
+ }
+ else
+ {
+ dsColumnName = parameter.SourceColumn;
+ }
if (row != null)
parameter.Value = row [dsColumnName, DataRowVersion.Current];
where.Append ("(");
@@ -186,7 +200,21 @@
parameter = deleteCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow));
- dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
+ if(tableMapping != null)
+ {
+ if(tableMapping.ColumnMappings.Count > 0)
+ {
+ dsColumnName = tableMapping.ColumnMappings[parameter.SourceColumn].DataSetColumn;
+ }
+ else
+ {
+ dsColumnName = parameter.SourceColumn;
+ }
+ }
+ else
+ {
+ dsColumnName = parameter.SourceColumn;
+ }
if (row != null)
parameter.Value = row [dsColumnName, DataRowVersion.Current];
@@ -229,7 +257,21 @@
SqlParameter parameter = insertCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow));
- dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
+ if(tableMapping != null)
+ {
+ if(tableMapping.ColumnMappings.Count > 0)
+ {
+ dsColumnName = tableMapping.ColumnMappings[parameter.SourceColumn].DataSetColumn;
+ }
+ else
+ {
+ dsColumnName = parameter.SourceColumn;
+ }
+ }
+ else
+ {
+ dsColumnName = parameter.SourceColumn;
+ }
if (row != null)
parameter.Value = row [dsColumnName];
@@ -276,7 +318,21 @@
SqlParameter parameter = updateCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow));
- dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
+ if(tableMapping != null)
+ {
+ if(tableMapping.ColumnMappings.Count > 0)
+ {
+ dsColumnName = tableMapping.ColumnMappings[parameter.SourceColumn].DataSetColumn;
+ }
+ else
+ {
+ dsColumnName = parameter.SourceColumn;
+ }
+ }
+ else
+ {
+ dsColumnName = parameter.SourceColumn;
+ }
if (row != null)
parameter.Value = row [dsColumnName, DataRowVersion.Proposed];
@@ -299,7 +355,21 @@
if (!isKey) {
parameter = updateCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow));
- dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
+ if(tableMapping != null)
+ {
+ if(tableMapping.ColumnMappings.Count > 0)
+ {
+ dsColumnName = tableMapping.ColumnMappings[parameter.SourceColumn].DataSetColumn;
+ }
+ else
+ {
+ dsColumnName = parameter.SourceColumn;
+ }
+ }
+ else
+ {
+ dsColumnName = parameter.SourceColumn;
+ }
if (row != null)
parameter.Value = row [dsColumnName];
@@ -312,7 +382,21 @@
parameter = updateCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow));
- dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
+ if(tableMapping != null)
+ {
+ if(tableMapping.ColumnMappings.Count > 0)
+ {
+ dsColumnName = tableMapping.ColumnMappings[parameter.SourceColumn].DataSetColumn;
+ }
+ else
+ {
+ dsColumnName = parameter.SourceColumn;
+ }
+ }
+ else
+ {
+ dsColumnName = parameter.SourceColumn;
+ }
if (row != null)
parameter.Value = row [dsColumnName];
@@ -417,6 +501,8 @@
if ((bool) schemaRow ["IsHidden"])
return false;
if ((bool) schemaRow ["IsRowVersion"])
+ return false;
+ if ((bool) schemaRow ["IsReadOnly"])
return false;
return true;
}
--------------080102040000090508030003--