ConflictOptions ConflictOptions ConflictOptions ConflictOptions Enum


确定 ASP.NET 数据源控件在更新或删除数据时如何处理数据冲突。Determines how ASP.NET data source controls handle data conflicts when updating or deleting data.

public enum class ConflictOptions
public enum ConflictOptions
type ConflictOptions = 
Public Enum ConflictOptions


CompareAllValues CompareAllValues CompareAllValues CompareAllValues 1

数据源控件使用 UpdateDelete 方法的 oldValues 集合来确定数据是否已被其他进程更改。A data source control uses the oldValues collection of the Update and Delete methods to determine whether the data has been changed by another process.

OverwriteChanges OverwriteChanges OverwriteChanges OverwriteChanges 0

数据源控件使用数据行自己的值覆盖该行中的所有值。A data source control overwrites all values in a data row with its own values for the row.


并发控制是一种技术, 当多个客户端访问和操作相同数据时, 数据存储使用该技术来控制如何在存储区中读取和更改数据。Concurrency control is a technique that data stores use to control how data is read and changed in the store when multiple clients are accessing and manipulating the same data. 例如, 一个客户端读取数据并向用户显示数据, 而另一个客户端读取相同的数据, 并将其呈现给其他用户。For example, one client reads data and presents it to a user, while another client reads the same data, and presents it to a different user. 如果这两个用户更新数据并将其提交到数据存储, 则可能会发生一些意外的结果, 因为客户端可能会为同一数据更新不同的值。If both users update the data and submit it to the data storage, some unexpected result might occur, because the clients might update different values for the same data. 这被视为冲突。This is considered a conflict.

为 ASP.NET 数据源控件定义的属性用于确定当基础数据存储使用开放式并发时控件如何处理基础数据存储中的数据冲突,而删除或更新操作为ConflictDetection执行.The ConflictDetection property that is defined for ASP.NET data source controls is used to determine how a control handles data conflicts in the underlying data storage when the underlying data storage is using optimistic concurrency and a delete or update operation is performed.

默认情况下, ConflictDetection该属性设置为 OverwriteChanges, 这意味着, 数据源控件将覆盖数据源控件第一次从行中读取数据到更新行时对数据行所做的任何更改。By default, the ConflictDetection property is set to OverwriteChanges, which means the data source control will overwrite any changes made to a data row between the time the data source control first read data from the row and the time that the row is updated. 主键用于查找将更新或删除的数据行, 但不执行任何其他数据比较。The primary key is used for locating the data row that will be updated or deleted, but no other comparison of the data is performed. 但是, 如果将数据源控件配置为使用 CompareAllValues 选项, 则控件将传递oldValues UpdateDelete方法的集合中的原始数据, 以便仅在这些值与数据存储中当前的值匹配。If the data source control is configured to use the CompareAllValues option, however, the control passes the original data in the oldValues collections of the Update and Delete methods so that you can write logic to update or delete data only if these values match the values currently in the data storage. 匹配值指示数据自读取后未发生更改。The matching values indicate that the data has not changed since the time it was read.