I need to convert a Datetime? to a string. The ?? operator dosent work and calling tostring on a null would make things fall over. Any advice on how to handle datetime? Thanks
Below is my code for context. o.CustomerRequiredDate is a Datetime? and PredictedActivationDate is a string. Both need to stay as the datatype they currently are.
{
rsp = (from r in db.btRequests
join o in db.NewOrders
on r.ID equals o.RequestId
join s in db.Status
on r.Status equals s.ID.ToString()
select new DataLayer.OrderResponse
{
RequestID = requestID,
Message = s.StatusDescription,
OrderStatus = r.Status.ToString(),
PredictedActivationDate =r.Status == "3" || r.Status == "4" || r.Status == "5"
|| r.Status == "6" || r.Status == "9" ? (o.CustomerRequiredDate ?? ""): ""
}).FirstOrDefault();
You could do