如果我有许多SqlDate类型的属性或者Date?,这种检查属性是否变化的方式可能是单调的。
您将如何实施此检查?也许作为SqlDate类型的扩展方法?或者有更常见的方式吗?
Public Property StayDate() As SqlDateTime
Get
Return _StayDate
End Get
Set(ByVal value As SqlDateTime)
If (value.IsNull And Not _StayDate.IsNull) OrElse
(Not value.IsNull And _StayDate.IsNull) OrElse
(value <> _StayDate) Then
_Changed = True
End If
_StayDate = value
End Set
End Property
转换后的C#:
public SqlDateTime StayDate {
get { return _StayDate; }
set {
if ((value.IsNull & !_StayDate.IsNull) ||
(!value.IsNull & _StayDate.IsNull) ||
(value != _StayDate))
{
_Changed = true;
}
_StayDate = value;
}
}