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


C# DataTable.NewNotInitializedRow方法代码示例

本文整理汇总了C#中System.Data.DataTable.NewNotInitializedRow方法的典型用法代码示例。如果您正苦于以下问题:C# DataTable.NewNotInitializedRow方法的具体用法?C# DataTable.NewNotInitializedRow怎么用?C# DataTable.NewNotInitializedRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.DataTable的用法示例。


在下文中一共展示了DataTable.NewNotInitializedRow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddChangedRow

		private void AddChangedRow (Hashtable addedRows, DataTable copyTable, DataRow row)
		{
			if (addedRows.ContainsKey (row))
				return;

			foreach (DataRelation relation in row.Table.ParentRelations) {
				DataRow parent = ( row.RowState != DataRowState.Deleted ?
						   row.GetParentRow (relation) :
						   row.GetParentRow (relation, DataRowVersion.Original)
						   );
				if (parent == null)
					continue;
				// add the parent row
				DataTable parentCopyTable = copyTable.DataSet.Tables [parent.Table.TableName];
				AddChangedRow (addedRows, parentCopyTable, parent);
			}

			// add the current row
			DataRow newRow = copyTable.NewNotInitializedRow ();
			copyTable.Rows.AddInternal (newRow);
			// Don't check for ReadOnly, when cloning data to new uninitialized row.
			row.CopyValuesToRow (newRow, false);
			newRow.XmlRowID = row.XmlRowID;
			addedRows.Add (row, row);
		}
开发者ID:t-ashula,项目名称:mono,代码行数:25,代码来源:DataSet.cs

示例2: MergeRow

		// merge a row into a target table.
		private static void MergeRow(DataTable targetTable, DataRow row, bool preserveChanges)
		{
			DataColumnCollection columns = row.Table.Columns;
			DataColumn[] primaryKeys = targetTable.PrimaryKey;
			DataRow targetRow = null;
			DataRowVersion version = DataRowVersion.Default;
			if (row.RowState == DataRowState.Deleted)
				version = DataRowVersion.Original;

			if (primaryKeys != null && primaryKeys.Length > 0) // if there are any primary key.
			{
				// initiate an array that has the values of the primary keys.
				object[] keyValues = new object[primaryKeys.Length];
				
				for (int j = 0; j < keyValues.Length; j++)
				{
					keyValues[j] = row[primaryKeys[j].ColumnName, version];
				}
			
				// find the row in the target table.
				targetRow = targetTable.Rows.Find(keyValues, DataViewRowState.OriginalRows);
				if (targetRow == null)
					targetRow = targetTable.Rows.Find(keyValues);
			}
			// row doesn't exist in target table, or there are no primary keys.
			// create new row and copy values from source row to the new row.
			if (targetRow == null)
			{ 
				DataRow newRow = targetTable.NewNotInitializedRow();
				row.CopyValuesToRow(newRow);
				targetTable.Rows.AddInternal (newRow);
			}
			// row exists in target table, and presere changes is false - 
			// change the values of the target row to the values of the source row.
			else if (!preserveChanges)
			{
				row.CopyValuesToRow(targetRow);
			}
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:40,代码来源:MergeManager.cs

示例3: AddChangedRow

		private void AddChangedRow (Hashtable addedRows, DataTable copyTable, DataRow row)
		{
			if (addedRows.ContainsKey (row)) return;

			foreach (DataRelation relation in row.Table.ParentRelations) {
				DataRow parent = row.GetParentRow (relation);
				if (parent == null)
					continue;
				// add the parent row
				DataTable parentCopyTable = copyTable.DataSet.Tables [parent.Table.TableName];
				AddChangedRow (addedRows, parentCopyTable, parent);
			}

			// add the current row
			DataRow newRow = copyTable.NewNotInitializedRow();
			copyTable.Rows.AddInternal(newRow);
			row.CopyValuesToRow (newRow);
			newRow.XmlRowID = row.XmlRowID;
			addedRows.Add (row, row);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:20,代码来源:DataSet.cs


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