请教大家一个微软PetShow例子的问题
按照微软件的PetShop的例子,一个表可以定义一个类,如
public class LineItemInfo {
// Internal member variables
private string _id;
private string _productName;
private int _line;
private int _quantity;
private decimal _price;
public LineItemInfo(){}
/// <summary>
/// Constructor with specified initial values
/// </summary>
/// <param name="id">Item Id</param>
/// <param name="line">Line number</param>
/// <param name="qty">Quanity in order</param>
/// <param name="price">Order item price</param>
public LineItemInfo(string id, string name, int line, int qty, decimal price){
this._id = id;
this._productName = name;
this._line = line;
this._price = price;
this._quantity = qty;
}
// Properties
public string ItemId {
get { return _id; }
set { _id = value; }
}
public string Name {
get { return _productName; }
set { _productName = value; }
}
public int Line {
get { return _line; }
set { _line = value; }
}
public int Quantity {
get { return _quantity; }
set { _quantity = value; }
}
public decimal Price {
get { return _price; }
set { _price = value; }
}
public decimal SubTotal {
get { return _price * _quantity; }
}
}
操作的时间,可以这么写
itemParms[0].Value = item.Line;
itemParms[1].Value = item.ItemId;
itemParms[2].Value = item.Quantity;
itemParms[3].Value = item.Price;
现在存在点问题,如果给某个字段赋空值如何处理,前台传过来的是一个LineItemInfo 变量,它的整型属性没法赋成null。