mysql - error c# System.NullReferenceException -
i have code: public ordertotalmodel getordertotalmodelbyagentid(string agentids = null, datetime? fromdate = null, datetime? todate = null) { var session = sessionmanager.currentsession; truncateamount truncateamount = new truncateamount(); string sql = @" select sum(o.totalquantity) totalquantity,sum(o.totalamount) totalamount orders o join workflows w on w.step = o.status inner join agents on a.id = o.agentid w.step = o.status , w.external = true , w.inactive = false , o.agentid in (:agentids) , o.approved = true"; //tu ngay if (fromdate.hasvalue) { sql += " , date(o.created) >= date(:fromdate)"; } // den ngay if (todate.hasvalue) { sql += " , date(o.created) <= date(:todate)"; ...