本文整理汇总了C#中System.Data.DataColumn.CompareValueTo方法的典型用法代码示例。如果您正苦于以下问题:C# DataColumn.CompareValueTo方法的具体用法?C# DataColumn.CompareValueTo怎么用?C# DataColumn.CompareValueTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataColumn
的用法示例。
在下文中一共展示了DataColumn.CompareValueTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SilentlySetValue
internal void SilentlySetValue(DataRow dr, DataColumn dc, DataRowVersion version, object newValue) {
// get record for version
int record = dr.GetRecordFromVersion(version);
bool equalValues = false;
if (DataStorage.IsTypeCustomType(dc.DataType) && newValue != dc[record]) {
// if UDT storage, need to check if reference changed. See bug 385182
equalValues = false;
}
else {
equalValues = dc.CompareValueTo(record, newValue, true);
}
// if expression has changed
if (!equalValues) {
int[] oldIndex = dr.Table.RemoveRecordFromIndexes(dr, version);// conditional, if it exists it will try to remove with no event fired
dc.SetValue(record, newValue);
int[] newIndex = dr.Table.InsertRecordToIndexes(dr, version);// conditional, it will insert if it qualifies, no event will be fired
if (dr.HasVersion(version)) {
if (version != DataRowVersion.Original) {
dr.Table.RecordChanged(oldIndex, newIndex);
}
if (dc.dependentColumns != null) {
//BugBug - passing in null for cachedRows. This means expression columns as keys does not work when key changes.
dc.Table.EvaluateDependentExpressions(dc.dependentColumns, dr, version, null);
}
}
}
dr.ResetLastChangedColumn();
}
示例2: 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();
}