c# - Linq to entity framework error when using datetimeoffset -


I'm getting a strange error and I can not fix it, can someone help?

The code below fails because it looks like o.ordered.DateTime.ToShortDateString () (This works when the part is commented on ). o.ordered is a datetimeoffset . There is an error in this below. I've tried some different versions like using toshortdatestring instead of date and tostring . from the LINQ method 'System.String ToShortDateString ()' method is not recognized, and this method can not be translated into the store expression o Bedb.onlineOrders of the above BeOrders = equals join BEdb.order_Statuses on o.status s.ID where o.custCode == pp.AccountID new DataLayer.OrderStatusItem {select city = o.city, customersOrderRef = o.customersOrderRef, date = (o.actualDelivery ?? o.plannedDelivery), DATE1 = (o.actualCease ?? o.actualCease), number = ordered o.number, = o.ordered.DateTime.ToShortDateString (), postal code = o.postCode state = s. Status, stockcode = o.stockcode, updatedByAccount = o.UpdatedByAccount};

The data provider used to translate the LINQ code into SQL ToShortDateString < / Code>. Because of that, you can not use it in a LINQ query that is sent to the database. You need to call this method after the data has been returned from the database:

  on the BeOrders = (from BEdb.onlineOrders in o.status to join BEdb.order_Statuses equals s.ID where o.custCode == select pp. Sisiaidiai new {city = o.city, customer orders Arif = O. Customers order Arf, date = (Oaktiv delivery? o Oplend delivery) date 1 = (Octal seizure? O octal season), number = o.number, ordered = o.ordered, postCode = o.postCode, position = s.status, stockCode = o.stockcode, up DatedByAccount = o.UpdatedByAccount}). ToList () Select (x = & gt; New Data Layer .OrderStatusItem {city = x.city, customersOrderRef = x.customersOrderRef, date = x.date, DATE1 = x.date1, number = x.number, ordered = x.ordered. DateTime.ToShortDateString (), postal code = x.postCode, status = x.status, stockCode = x.stockCode, UpdatedByAccount = x.UpdatedByAccount};   

Btw: there is another solution That the code of small stature is produced:

  var BeOrders = (BEdb.onlineOrders contains os from O.SSSSSI. Select O.Kastcode == PPACDID New {O, S} in B. AD.Order_Status in SISS.) Olist (). The Select (x = & gt; New DataLayer.OrderStatusItem {city = xocity, customersOrderRef = xocustomersOrderRef, date = (xoactualDelivery ?? xoplannedDelivery), DATE1 = (xoactualCease ?? xoactualCease), number = xonumber, order = xoordered.DateTime.ToShortDateString (), postcode = xopostCode, status = xsstatus, Stokkod = xostockCode, UpdatedByAccount = xoUpdatedByAccount};   

the difference between the two versions of that first version databases Asks the columns where you will return the second version to all the columns of two tables.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -