System.Data.OracleClient.OracleCommandBuilder,如何生成UpdateCommand

private  IDbCommand BuildUpdateCommand(DataTableMapping mappings, DataRow dataRow)
{
      IDbCommand command1 
= this.InitializeCommand(this.UpdateCommand);
      StringBuilder builder1 
= this.GetStringBuilder();
      
int num1 = 0;
      
string text1 = " SET ";
      builder1.Append(
"UPDATE ");
      builder1.Append(
this.QuotedBaseTableName);
      
int num2 = this._dbSchemaRows.Length;
      
for (int num3 = 0; num3 < num2; num3++)
      
{
            DBSchemaRow row1 
= this._dbSchemaRows[num3];
            
if (((row1 != null&& (row1.BaseColumnName.Length != 0)) && this.IncludeInUpdateSet(row1))
            
{
                  
object obj1 = null;
                  
string text2 = this._sourceColumnNames[num3];
                  
if ((mappings != null&& (dataRow != null))
                  
{
                        DataColumn column1 
= this.GetDataColumn(text2, mappings, dataRow);
                        
if ((column1 == null|| (row1.IsReadOnly && column1.ReadOnly))
                        
{
                              
goto Label_013D;
                        }

                        obj1 
= this.GetColumnValue(dataRow, column1, DataRowVersion.Current);
                        
if (this.IsNotBehavior(CommandBuilderBehavior.UpdateSetSameValue))
                        
{
                              
object obj2 = this.GetColumnValue(dataRow, column1, DataRowVersion.Original);
                              
if ((obj2 == obj1) || ((obj2 != null&& obj2.Equals(obj1)))
                              
{
                                    
goto Label_013D;
                              }

                        }

                  }

                  builder1.Append(text1);
                  text1 
= "";
                  builder1.Append(
this.QuotedColumn(row1.BaseColumnName));
                  builder1.Append(
" = ");
                  builder1.Append(
this.CreateParameterForValue(command1, text2, DataRowVersion.Current, num1, obj1, row1));
                  num1
++;
            }

      Label_013D:;
      }

      
bool flag1 = 0 == num1;
      num1 
= this.BuildWhereClause(mappings, dataRow, builder1, command1, num1, true);
      command1.CommandText 
= builder1.ToString();
      OracleCommandBuilder.RemoveExtraParameters(command1, num1);
      
this.UpdateCommand = command1;
      
if (!flag1)
      
{
            
return command1;
      }

      
return null;
}

你可能感兴趣的:(command)