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


C# DataRow.HasVersion方法代码示例

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


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

示例1: ImportRow

		/// <summary>
		/// Copies a DataRow into a DataTable, preserving any
		/// property settings, as well as original and current values.
		/// </summary>
		public void ImportRow (DataRow row)
		{
			if (row.RowState == DataRowState.Detached)
				return;

			DataRow newRow = NewNotInitializedRow ();

			int original = -1;
			if (row.HasVersion (DataRowVersion.Original)) {
				original = row.IndexFromVersion (DataRowVersion.Original);
				newRow.Original = RecordCache.NewRecord ();
				RecordCache.CopyRecord (row.Table, original, newRow.Original);
			}

			if (row.HasVersion (DataRowVersion.Current)) {
				int current = row.IndexFromVersion (DataRowVersion.Current);
				if (current == original) {
					newRow.Current = newRow.Original;
				} else {
					newRow.Current = RecordCache.NewRecord ();
					RecordCache.CopyRecord (row.Table, current, newRow.Current);
				}
			}

			//Import the row only if RowState is not detached
			//Validation for Deleted Rows happens during Accept/RejectChanges
			if (row.RowState != DataRowState.Deleted)
				newRow.Validate ();
			else
				AddRowToIndexes (newRow);
			Rows.AddInternal(newRow);

			if (row.HasErrors)
				row.CopyErrors (newRow);
		}
开发者ID:shana,项目名称:mono,代码行数:39,代码来源:DataTable.cs

示例2: CheckRowVersion

		private void CheckRowVersion(DataRow dr)
		{
			Console.WriteLine("");
			if (dr.HasVersion(DataRowVersion.Current)) Console.WriteLine("Has " + DataRowVersion.Current.ToString());
			if (dr.HasVersion(DataRowVersion.Default)) Console.WriteLine("Has " + DataRowVersion.Default.ToString());
			if (dr.HasVersion(DataRowVersion.Original)) Console.WriteLine("Has " + DataRowVersion.Original.ToString());
			if (dr.HasVersion(DataRowVersion.Proposed)) Console.WriteLine("Has " + DataRowVersion.Proposed.ToString());
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:DataRowTest2.cs

示例3: CopyRow

		internal void CopyRow (DataRow fromRow, DataRow toRow)
		{
			if (fromRow.HasErrors)
				fromRow.CopyErrors (toRow);

			if (fromRow.HasVersion (DataRowVersion.Original))
				toRow.Original = toRow.Table.RecordCache.CopyRecord (this, fromRow.Original, -1);

			if (fromRow.HasVersion (DataRowVersion.Current)) {
				if (fromRow.Original != fromRow.Current)
					toRow.Current = toRow.Table.RecordCache.CopyRecord (this, fromRow.Current, -1);
				else
					toRow.Current = toRow.Original;
			}
		}
开发者ID:shana,项目名称:mono,代码行数:15,代码来源:DataTable.cs

示例4: BuildRowInfo

        private void BuildRowInfo(StringBuilder builder, DataRow row)
        {
            if (row==null)
            {
                return;
            }
            builder.AppendLine("Row State :" + row.RowState );
            builder.AppendLine("Columns: ");
            foreach (DataColumn column in row.Table.Columns)
            {
                object value ;
                if (row.HasVersion(DataRowVersion.Current))
                {
                    value = row[column];
                }
                else
                {
                    value = row[column, DataRowVersion.Original];
                }

                builder.AppendLine(string.Format("{0} = {1};", column.ColumnName, value));

            }
        }
开发者ID:rentianhua,项目名称:AgileMVC,代码行数:24,代码来源:MonitoringPopulateLogEntry.cs

示例5: IsChanged

    private bool IsChanged(DataRow row, DataColumn col, out object newValue)
    {
      newValue = null;
      if (!row.HasVersion(DataRowVersion.Original) || !row.HasVersion(DataRowVersion.Current))
        return false;
      var orig = row[col, DataRowVersion.Original];
      var curr = row[col, DataRowVersion.Current];

      if (orig == DBNull.Value && curr == DBNull.Value)
        return false;

      newValue = curr;
      if (orig == DBNull.Value && curr == DBNull.Value)
        return true;

      return !orig.Equals(curr);
    }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:17,代码来源:EditorWindow.cs

示例6: InsertRecordToIndexes

// InsertRecordToIndexes inserts the given record (using row and version) to all indexes and it  stores and returns the position of inserted
// record to each index
// IT SHOULD NOT CAUSE ANY EVENT TO BE FIRED
        internal int[] InsertRecordToIndexes(DataRow row, DataRowVersion  version) {
            int    indexCount          =  LiveIndexes.Count;
            int [] positionIndexes =  new int[indexCount];

            int recordNo = row.GetRecordFromVersion(version);
            DataViewRowState states = row.GetRecordState(recordNo);

            while (--indexCount >= 0) {
                if (row.HasVersion(version)) {
                    if ((states & indexes[indexCount].RecordStates) != DataViewRowState.None) {
                        positionIndexes [indexCount] = indexes[indexCount].InsertRecordToIndex(recordNo);
                    }
                    else {
                        positionIndexes [indexCount] = -1;
                    }
                }
            }
            return positionIndexes;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:22,代码来源:DataTable.cs

示例7: ImportRow

		/// <summary>
		/// Copies a DataRow into a DataTable, preserving any 
		/// property settings, as well as original and current values.
		/// </summary>
		public void ImportRow (DataRow row) 
		{
			DataRow newRow = NewNotInitializedRow();

			int original = -1;
			if (row.HasVersion(DataRowVersion.Original)) {
				original = row.IndexFromVersion(DataRowVersion.Original);
				newRow.Original = RecordCache.NewRecord();
				RecordCache.CopyRecord(row.Table,original,newRow.Original);
			}

			if (row.HasVersion(DataRowVersion.Current)) {
				int current = row.IndexFromVersion(DataRowVersion.Current);
				if (current == original)
					newRow.Current = newRow.Original;
				else {
					newRow.Current = RecordCache.NewRecord();
					RecordCache.CopyRecord(row.Table,current,newRow.Current);
				}
			}

			if (EnforceConstraints)
				// we have to check that the new row doesn't colide with existing row
				Rows.ValidateDataRowInternal(newRow);

			Rows.AddInternal(newRow);		
	
			if (row.HasErrors) {
				row.CopyErrors(newRow);
			}
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:35,代码来源:DataTable.cs

示例8: HasChanged

        /// <summary>
        /// Checks, if value of given column of given row is changed.
        /// </summary>
        /// <param name="row">DataRow with values to check.</param>
        /// <param name="column">Column name.</param>
        /// <returns>
        /// If original value is not null, use returns Equals. Otherwise returns 
        /// true if current value is null too.
        /// </returns>
        public static bool HasChanged(DataRow row, string column)
        {
            if (row == null)
                throw new ArgumentNullException("row");
            if (String.IsNullOrEmpty(column))
                throw new ArgumentException(Resources.Error_EmptyString, "column");

            // If new row or deleted row, then it definetelly changed
            if (row.RowState == DataRowState.Deleted || row.RowState == DataRowState.Added)
                return true;

            // Check for availble versions
            if (!row.HasVersion(DataRowVersion.Original)
                || !row.HasVersion(DataRowVersion.Current))
            {
                // Nothing to compare
                return false;
            }

            // Get values
            object original = row[column, DataRowVersion.Original];
            object current = row[column, DataRowVersion.Current];

            // If original is not null, use Equals. Otherwise current should be null to.
            return !CompareObjects(original, current);
        }
开发者ID:tdhieu,项目名称:openvss,代码行数:35,代码来源:DataInterpreter.cs

示例9: AssertConstraint

		internal override void AssertConstraint(DataRow row)
		{	
			if (IsPrimaryKey && row.HasVersion(DataRowVersion.Default)) {
				for (int i = 0; i < Columns.Length; i++) {
					if (row.IsNull(Columns[i])) {
						throw new NoNullAllowedException("Column '" + Columns[i].ColumnName + "' does not allow nulls.");
					}
				}
			}
			
			if (Index == null) {
				Index = Table.GetIndex(Columns,null,DataViewRowState.None,null,false);
			}

			if (Index.HasDuplicates) {
				throw new ConstraintException(GetErrorMessage(row));
			}
		}
开发者ID:shana,项目名称:mono,代码行数:18,代码来源:UniqueConstraint.cs

示例10: SilentlySetValue

 internal void SilentlySetValue(DataRow dr, DataColumn dc, DataRowVersion version, object newValue)
 {
     int recordFromVersion = dr.GetRecordFromVersion(version);
     bool flag = false;
     if (DataStorage.IsTypeCustomType(dc.DataType) && (newValue != dc[recordFromVersion]))
     {
         flag = false;
     }
     else
     {
         flag = dc.CompareValueTo(recordFromVersion, newValue, true);
     }
     if (!flag)
     {
         int[] oldIndex = dr.Table.RemoveRecordFromIndexes(dr, version);
         dc.SetValue(recordFromVersion, newValue);
         int[] newIndex = dr.Table.InsertRecordToIndexes(dr, version);
         if (dr.HasVersion(version))
         {
             if (version != DataRowVersion.Original)
             {
                 dr.Table.RecordChanged(oldIndex, newIndex);
             }
             if (dc.dependentColumns != null)
             {
                 dc.Table.EvaluateDependentExpressions(dc.dependentColumns, dr, version, null);
             }
         }
     }
     dr.ResetLastChangedColumn();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:DataTable.cs

示例11: BuildDropForeignKey

        /// <summary>
        /// Builds DROP FOREIGN KEY statement
        /// </summary>
        /// <param name="target">String builder, used to build query.</param>
        /// <param name="key">DataRow with foreign key data.</param>
        private void BuildDropForeignKey(StringBuilder target, DataRow key)
        {
            target.Append("\nDROP FOREIGN KEY ");
            QueryBuilder.WriteOldIdentifier(key, ForeignKey.Name, target);

            // Write trailing ","
            target.Append(",");

            // If we have index with same name, drop it too
            if (key.HasVersion(DataRowVersion.Original))
            {
                DataRow index = FindIndex(DataInterpreter.GetStringNotNull(key, ForeignKey.Name, DataRowVersion.Original));
                if (index != null)
                    BuildDropIndex(target, index);
            }
        }
开发者ID:tdhieu,项目名称:openvss,代码行数:21,代码来源:TableDocument.cs

示例12: RemoveRecordFromIndexes

 internal int[] RemoveRecordFromIndexes(DataRow row, DataRowVersion version)
 {
     int count = this.LiveIndexes.Count;
     int[] numArray = new int[count];
     int recordFromVersion = row.GetRecordFromVersion(version);
     DataViewRowState recordState = row.GetRecordState(recordFromVersion);
     while (--count >= 0)
     {
         if (row.HasVersion(version) && ((recordState & this.indexes[count].RecordStates) != DataViewRowState.None))
         {
             int index = this.indexes[count].GetIndex(recordFromVersion);
             if (index > -1)
             {
                 numArray[count] = index;
                 this.indexes[count].DeleteRecordFromIndex(index);
             }
             else
             {
                 numArray[count] = -1;
             }
         }
         else
         {
             numArray[count] = -1;
         }
     }
     return numArray;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:DataTable.cs

示例13: InsertRecordToIndexes

 internal int[] InsertRecordToIndexes(DataRow row, DataRowVersion version)
 {
     int count = this.LiveIndexes.Count;
     int[] numArray = new int[count];
     int recordFromVersion = row.GetRecordFromVersion(version);
     DataViewRowState recordState = row.GetRecordState(recordFromVersion);
     while (--count >= 0)
     {
         if (row.HasVersion(version))
         {
             if ((recordState & this.indexes[count].RecordStates) != DataViewRowState.None)
             {
                 numArray[count] = this.indexes[count].InsertRecordToIndex(recordFromVersion);
             }
             else
             {
                 numArray[count] = -1;
             }
         }
     }
     return numArray;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:22,代码来源:DataTable.cs

示例14: CheckConstraint

 internal override void CheckConstraint(DataRow childRow, DataRowAction action)
 {
     if (((((action == DataRowAction.Change) || (action == DataRowAction.Add)) || (action == DataRowAction.Rollback)) && ((this.Table.DataSet != null) && this.Table.DataSet.EnforceConstraints)) && childRow.HasKeyChanged(this.childKey))
     {
         DataRowVersion version = (action == DataRowAction.Rollback) ? DataRowVersion.Original : DataRowVersion.Current;
         object[] keyValues = childRow.GetKeyValues(this.childKey);
         if (childRow.HasVersion(version))
         {
             DataRow row = DataRelation.GetParentRow(this.ParentKey, this.ChildKey, childRow, version);
             if ((row != null) && row.inCascade)
             {
                 object[] objArray2 = row.GetKeyValues(this.parentKey, (action == DataRowAction.Rollback) ? version : DataRowVersion.Default);
                 int record = childRow.Table.NewRecord();
                 childRow.Table.SetKeyValues(this.childKey, objArray2, record);
                 if (this.childKey.RecordsEqual(childRow.tempRecord, record))
                 {
                     return;
                 }
             }
         }
         object[] values = childRow.GetKeyValues(this.childKey);
         if (!this.IsKeyNull(values) && !this.parentKey.GetSortIndex().IsKeyInIndex(values))
         {
             if ((this.childKey.Table == this.parentKey.Table) && (childRow.tempRecord != -1))
             {
                 int index = 0;
                 index = 0;
                 while (index < values.Length)
                 {
                     DataColumn column = this.parentKey.ColumnsReference[index];
                     object obj2 = column.ConvertValue(values[index]);
                     if (column.CompareValueTo(childRow.tempRecord, obj2) != 0)
                     {
                         break;
                     }
                     index++;
                 }
                 if (index == values.Length)
                 {
                     return;
                 }
             }
             throw ExceptionBuilder.ForeignKeyViolation(this.ConstraintName, keyValues);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:46,代码来源:ForeignKeyConstraint.cs

示例15: CheckConstraint

        internal override void CheckConstraint(DataRow childRow, DataRowAction action) {
            if ((action == DataRowAction.Change ||
                 action == DataRowAction.Add ||
                 action == DataRowAction.Rollback) &&
                Table.DataSet != null && Table.DataSet.EnforceConstraints &&
                childRow.HasKeyChanged(childKey)) {

                // This branch is for cascading case verification.
                DataRowVersion version = (action == DataRowAction.Rollback) ? DataRowVersion.Original : DataRowVersion.Current;
                object[] childKeyValues = childRow.GetKeyValues(childKey);
                // check to see if this is just a change to my parent's proposed value.
                if (childRow.HasVersion(version)) {
                    // this is the new proposed value for the parent.
                    DataRow parentRow = DataRelation.GetParentRow(this.ParentKey, this.ChildKey, childRow, version);
                    if(parentRow != null && parentRow.inCascade) {
                        object[] parentKeyValues = parentRow.GetKeyValues(parentKey, action == DataRowAction.Rollback ? version : DataRowVersion.Default);

                        int parentKeyValuesRecord = childRow.Table.NewRecord();
                        childRow.Table.SetKeyValues(childKey, parentKeyValues, parentKeyValuesRecord);
                        if (childKey.RecordsEqual(childRow.tempRecord, parentKeyValuesRecord)) {
                            return;
                        }
                    }
                }

                // now check to see if someone exists... it will have to be in a parent row's current, not a proposed.
                object[] childValues = childRow.GetKeyValues(childKey);
                if (!IsKeyNull(childValues)) {
                    Index parentIndex = parentKey.GetSortIndex();
                    if (!parentIndex.IsKeyInIndex(childValues)) {
                        // could be self-join constraint
                        if (childKey.Table == parentKey.Table && childRow.tempRecord != -1) {
                            int lo = 0;
                            for (lo = 0; lo < childValues.Length; lo++) {
                                DataColumn column = parentKey.ColumnsReference[lo];
                                object value = column.ConvertValue(childValues[lo]);
                                if (0 != column.CompareValueTo(childRow.tempRecord, value)) {
                                    break;
                                }
                            }
                            if (lo == childValues.Length) {
                                return;
                            }
                        }
                        throw ExceptionBuilder.ForeignKeyViolation(ConstraintName, childKeyValues);
                    }
                }
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:49,代码来源:ForeignKeyConstraint.cs


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