本文整理汇总了C#中System.Data.Common.DataTableMapping.GetColumnMappingBySchemaAction方法的典型用法代码示例。如果您正苦于以下问题:C# DataTableMapping.GetColumnMappingBySchemaAction方法的具体用法?C# DataTableMapping.GetColumnMappingBySchemaAction怎么用?C# DataTableMapping.GetColumnMappingBySchemaAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Common.DataTableMapping
的用法示例。
在下文中一共展示了DataTableMapping.GetColumnMappingBySchemaAction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateParameterValues
private void UpdateParameterValues(
IDbCommand command,
StatementType statementType,
DataRow row,
DataTableMapping tableMapping)
{
foreach (DbParameter parameter in command.Parameters)
{
// Process only input parameters
if ((parameter.Direction == ParameterDirection.Input || parameter.Direction == ParameterDirection.InputOutput) &&
!String.IsNullOrEmpty(parameter.SourceColumn))
{
DataColumn column = null;
/* Get the DataColumnMapping that matches the given
* column name
*/
DataColumnMapping columnMapping = tableMapping.GetColumnMappingBySchemaAction(
parameter.SourceColumn,
MissingMappingAction);
if (columnMapping != null)
{
column = columnMapping.GetDataColumnBySchemaAction(row.Table, null, MissingSchemaAction);
if (column != null)
{
DataRowVersion dataRowVersion = DataRowVersion.Default;
if (statementType == StatementType.Insert)
{
dataRowVersion = DataRowVersion.Current;
}
else if (statementType == StatementType.Update)
{
dataRowVersion = parameter.SourceVersion;
}
else if (statementType == StatementType.Delete)
{
dataRowVersion = DataRowVersion.Original;
}
if (parameter.SourceColumnNullMapping)
{
parameter.Value = IsNull(row[column, dataRowVersion]) ? 1 : 0;
}
else
{
parameter.Value = row[column, dataRowVersion];
}
}
}
}
}
}
示例2: Update
//.........这里部分代码省略.........
if (rowsAffected == 0)
{
throw new DBConcurrencyException("An attempt to execute an INSERT, UPDATE, or DELETE statement resulted in zero records affected.");
}
updated++;
/* 4. If the command is set to FirstReturnedRecord, then the
* first returned result is placed in the DataRow.
*
* We have nothing to do in this case as there are no
* support for batch commands.
*/
/* 5. Check if we have output parameters and they should
* be updated.
*
* Only output paraneters should be updated
*/
if (command.UpdatedRowSource == UpdateRowSource.OutputParameters ||
command.UpdatedRowSource == UpdateRowSource.Both)
{
// Process output parameters
foreach (IDataParameter parameter in command.Parameters)
{
if ((parameter.Direction == ParameterDirection.Output ||
parameter.Direction == ParameterDirection.ReturnValue ||
parameter.Direction == ParameterDirection.InputOutput) &&
parameter.SourceColumn != null &&
parameter.SourceColumn.Length > 0)
{
DataColumn column = null;
DataColumnMapping columnMapping = tableMapping.GetColumnMappingBySchemaAction(
parameter.SourceColumn,
this.MissingMappingAction);
if (columnMapping != null)
{
column = columnMapping.GetDataColumnBySchemaAction(
row.Table,
null,
this.MissingSchemaAction);
if (column != null)
{
row[column] = parameter.Value;
}
}
}
}
}
}
}
catch (Exception ex)
{
row.RowError = ex.Message;
updateException = ex;
}
if (updatingArgs.Status == UpdateStatus.Continue)
{
// 6. Raise RowUpdated event
RowUpdatedEventArgs updatedArgs = this.CreateRowUpdatedEvent(row, command, statementType, tableMapping);
this.OnRowUpdated(updatedArgs);
示例3: Update
//.........这里部分代码省略.........
updated++;
// http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=933212&SiteID=1
if (statementType == StatementType.Insert)
{
row.AcceptChanges();
}
/* 4. If the command is set to FirstReturnedRecord, then the
* first returned result is placed in the DataRow.
*
* We have nothing to do in this case as there are no
* support for batch commands.
*/
/* 5. Check if we have output parameters and they should
* be updated.
*
* Only output parameters should be updated
*/
if (command.UpdatedRowSource == UpdateRowSource.OutputParameters ||
command.UpdatedRowSource == UpdateRowSource.Both)
{
// Process output parameters
foreach (IDataParameter parameter in command.Parameters)
{
if ((parameter.Direction == ParameterDirection.Output ||
parameter.Direction == ParameterDirection.ReturnValue ||
parameter.Direction == ParameterDirection.InputOutput) &&
!String.IsNullOrEmpty(parameter.SourceColumn))
{
DataColumn column = null;
DataColumnMapping columnMapping = tableMapping.GetColumnMappingBySchemaAction(
parameter.SourceColumn,
MissingMappingAction);
if (columnMapping != null)
{
column = columnMapping.GetDataColumnBySchemaAction(
row.Table,
null,
MissingSchemaAction);
if (column != null)
{
row[column] = parameter.Value;
}
}
}
}
}
}
}
catch (Exception ex)
{
row.RowError = ex.Message;
updateException = ex;
}
if (updatingArgs != null && updatingArgs.Status == UpdateStatus.Continue)
{
// 6. Raise RowUpdated event
RowUpdatedEventArgs updatedArgs = CreateRowUpdatedEvent(row, command, statementType, tableMapping);
OnRowUpdated(updatedArgs);
示例4: GetDataColumn
private DataColumn GetDataColumn(
string columnName, DataTableMapping tableMapping, DataRow row)
{
DataColumn dataColumn = null;
// Get the DataColumnMapping that matches
// the given column name
DataColumnMapping columnMapping = tableMapping.GetColumnMappingBySchemaAction(
columnName, this.dataAdapter.MissingMappingAction);
if (columnMapping != null)
{
// Get the DataColumn for the given column name
dataColumn = columnMapping.GetDataColumnBySchemaAction(
row.Table,
null,
this.dataAdapter.MissingSchemaAction);
}
return dataColumn;
}