## XPO对象类中字段值通过运算后存入数据库中 ##
第一种不存入数据库,临时运算
[DisplayName("字段")]
public double CoalNum;
private double _SO2;
[DisplayName("SO2"),NonPersistent]
public double SO2 {
get { return _SO2; }
set {
_SO2 = (CoalNum * 0.012 * 0.8 * 2);
}
}
第二种字段存入数据库;但是运算过后数据会延迟存入数据库
[DisplayName("字段")]
public double CoalNum;
private double _SO2;
[DisplayName("SO2")]
public double SO2 {
get { return _SO2 = (CoalNum * 0.012 * 0.8 * 2); }
}
第三种都同时存入数据库
[DisplayName("字段")]
public double CoalNum;
[DisplayName("SO2")]
public double SO2;
protected override void OnSaving(){
SO2 = (CoalNum * 0.012 * 0.8 * 2);
}
评论已关闭