当前位置: 首页>>代码示例>>C#>>正文


C# DataTableMapping.GetColumnMappingBySchemaAction方法代码示例

本文整理汇总了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];
							}
						}
					}
				}
			}
		}
开发者ID:nakagami,项目名称:FirebirdSql.Data.FirebirdClient,代码行数:55,代码来源:FbDataAdapter.cs

示例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);
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:66,代码来源:FbDataAdapter.cs

示例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);
开发者ID:nakagami,项目名称:FirebirdSql.Data.FirebirdClient,代码行数:66,代码来源:FbDataAdapter.cs

示例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;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:21,代码来源:FbCommandBuilder.cs


注:本文中的System.Data.Common.DataTableMapping.GetColumnMappingBySchemaAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。