1、decimal属性值赋值为null值报错
DAO层定义方法: decimal GetHoursByOrderCode(string OrderCode);
在xml处理时要对sql返回结果增加null值处理,或者方法定义返回值未可空类型decimal? GetHoursByOrderCode(string OrderCode);但使用时要主要增加默认值处理TotalHours.GetValueOrDefault(0) * (decimal)item.Price;
2、实体类中嵌套其他实体类使用时要对使用的实体new对象不然会报未将引用对象设置到实例
public class WF_StationAcceptanceProjectInfo
{
public string ProjectId { get; set; }
public string ProjectCode { get; set; }
public List<WF_StationAcceptanceAction> ActionList { get; set; }
}
使用时:
WF_StationAcceptanceProjectInfo wf_stationacceptanceprojectinfo = new WF_StationAcceptanceProjectInfo();
StationAcceptancePlaceCode placecode = new StationAcceptancePlaceCode();
List<WF_StationAcceptanceAction> ActionList = new List<WF_StationAcceptanceAction>();
WF_StationAcceptanceAction action = new WF_StationAcceptanceAction();
action.ActionTime = list[0].LastModifyTime.ToString();
ActionList.Add(action);
wf_stationacceptanceprojectinfo.ActionList = ActionList;