问一下以下代码的e.ProposedValue是什么来的
1public partial class Northwind
2{
3 public partial class ProductsDataTable
4 {
5 public override void BeginInit()
6 {
7 this.ColumnChanging += ValidateColumn;
8 }
9
10 void ValidateColumn(object sender, DataColumnChangeEventArgs e)
11 {
12 if(e.Column.Equals(this.UnitPriceColumn))
13 {
14 if(!Convert.IsDBNull(e.ProposedValue) && (decimal)e.ProposedValue < 0)
15 {
16 throw new ArgumentException("UnitPrice cannot be less than zero", "UnitPrice");
17 }
18 }
19 else if (e.Column.Equals(this.UnitsInStockColumn) ||
20 e.Column.Equals(this.UnitsOnOrderColumn) ||
21 e.Column.Equals(this.ReorderLevelColumn))
22 {
23 if (!Convert.IsDBNull(e.ProposedValue) && (short)e.ProposedValue < 0)
24 {
25 throw new ArgumentException(string.Format("{0} cannot be less than zero", e.Column.ColumnName), e.Column.ColumnName);
26 }
27 }
28 }
29 }
1public partial class Northwind
2{
3 public partial class ProductsDataTable
4 {
5 public override void BeginInit()
6 {
7 this.ColumnChanging += ValidateColumn;
8 }
9
10 void ValidateColumn(object sender, DataColumnChangeEventArgs e)
11 {
12 if(e.Column.Equals(this.UnitPriceColumn))
13 {
14 if(!Convert.IsDBNull(e.ProposedValue) && (decimal)e.ProposedValue < 0)
15 {
16 throw new ArgumentException("UnitPrice cannot be less than zero", "UnitPrice");
17 }
18 }
19 else if (e.Column.Equals(this.UnitsInStockColumn) ||
20 e.Column.Equals(this.UnitsOnOrderColumn) ||
21 e.Column.Equals(this.ReorderLevelColumn))
22 {
23 if (!Convert.IsDBNull(e.ProposedValue) && (short)e.ProposedValue < 0)
24 {
25 throw new ArgumentException(string.Format("{0} cannot be less than zero", e.Column.ColumnName), e.Column.ColumnName);
26 }
27 }
28 }
29 }
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货