public FeeDetails GetFeeDetails(string admissionno)
{
var feedetails = from f in db.FeeDetails select f;
FeeDetails feedetail = feedetails.Where(f => f.AdmissionNo == admissionno).FirstOrDefault();
FeeDetails feedetailfinal = new FeeDetails();
feedetailfinal.Fee1 = feedetail.Fee1.ToString() != null ? Convert.ToInt32(feedetail.Fee1.ToString()) : 0;
feedetailfinal.Fee2 = feedetail.Fee2.ToString() != null ? Convert.ToInt32(feedetail.Fee2.ToString()) : 0;
feedetailfinal.Fee3 = feedetail.Fee3.ToString() != null ? Convert.ToInt32(feedetail.Fee3.ToString()) : 0;
feedetailfinal.Fee4 = feedetail.Fee4.ToString() != null ? Convert.ToInt32(feedetail.Fee4.ToString()) : 0;
feedetailfinal.Fee5 = feedetail.Fee5.ToString() != null ? Convert.ToInt32(feedetail.Fee5.ToString()) : 0;
return feedetailfinal;
}
答案 0 :(得分:0)
我相信你的每一行应该是这样的:
if(feedetail != null)
{
feedetailfinal.Fee1 = feedetail.Fee1 != null
? Convert.ToInt32(feedetail.Fee1)
: 0;
//other lines
}