cool hit counter [C#] DataRowState Evolution Memo_Intefrankly

[C#] DataRowState Evolution Memo


Environment..net 2.0

DataRow's row state will not be available for a while, so record it for your records.

The right operation is performed when the row belongs to the following state → Post-state evolution

Add to table dt.Rows.Add()

Modifying cell values row[x] = xx

Marker deletion row. Delete() [Note 1]

submit dt/row.AcceptChanges()

rollback dt/row.RejectChanges()

Detached

Added

Detached

Detached

Detached [Note 5]

Detached

Added

-[Note 2]

Added

Detached [Note 4]

Unchanged

Detached

Unchanged

-[Note 2]

Modified

Deleted

Unchanged

Unchanged

Modified

-[Note 2]

Modified

Deleted

Unchanged

Unchanged

Deleted

-[Note 2]

-[Note 3]

Deleted

Detached

Unchanged

Notes.

  1. Marker deletion means row. Delete(), not dt. Rows.Remove(row), which removes the row from the table completely
  2. Throw exception [System.ArgumentException: the row already belongs to this table (or another table)]
  3. throw an exception【System.Data.DeletedRowInaccessibleException: Information on a deleted row cannot be accessed through that row】。 Lines marked for deletion, more than Modifying cell values It can cause anomalies, As long as the visit is, as ifvar a = row[x]
  4. Added state rows that are Deleted become Detached (i.e., the row is removed completely), not Deleted, so be aware of the possibility of raising a collection-modified exception when performing traversal operations: foreach (DataRow r in dt. Rows) { r.Delete(); }
  5. The Detached row doesn't belong to any table, so executing the table's AcceptChanges/RejectChanges doesn't make sense for it, executing the row's own AcceptChanges raises an exception, and the RejectChanges don't throw, but do nothing

Other.

  • Only Detached rows can be added, because rows in other states must already belong to a table (and only to 1 table), so adding them will raise an exception
  • Iterating over rows will access all rows that are not in the Detached state, that is, Deleted rows will also be iterated over, and Rows.Count is also the count of rows containing Deleted rows
  • After executing the table's AcceptChanges(), the Deleted row is completely removed (becomes Detached), the rest of the rows become Unchanged, and the original value becomes the current value
  • After executing RejectChanges() on the table, the Added row is completely removed (becomes Detached), the rest of the rows become Unchanged, and the current value is changed back to the original value

MSDN Reference.https://msdn.microsoft.com/zh-cn/library/ww3k31w0(v=vs.80).aspx

- Man Bi -


Recommended>>
1、System resource limits for ulimit on linux
2、You pay me 3000 a month why should I give you 8000 for the work you do
3、Indepth understanding of Java concurrency synchronized implementation principle
4、Deep learning robotics which technology directions are most likely to create sparks
5、MidAutumn BenefitsBeautiful React Backend Source Code True Release

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号