Im getting an odd error and I cant fix it. Can someone help?
The below code fails because it dosent like o.ordered.DateTime.ToShortDateString()
(it works when that part is commented out). o.ordered
is a datetimeoffset
. There error it gives is below. I have tried a few diffrent versions like using date
and tostring
rather than toshortdatestring
.
LINQ to Entities does not recognize the method 'System.String ToShortDateString()' method, and this method cannot be translated into a store expression.
var BeOrders = from o in BEdb.onlineOrders
join s in BEdb.order_Statuses
on o.status equals s.ID
where o.custCode == pp.AccountID
select new DataLayer.OrderStatusItem {
city = o.city,
customersOrderRef = o.customersOrderRef,
date = (o.actualDelivery ?? o.plannedDelivery),
date1 = (o.actualCease ?? o.actualCease),
number = o.number,
ordered = o.ordered.DateTime.ToShortDateString(),
postCode = o.postCode,
status = s.status,
stockCode = o.stockCode,
UpdatedByAccount = o.UpdatedByAccount
};