Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6390699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:34:47+00:00 2026-05-25T03:34:47+00:00

Im getting an odd error and I cant fix it. Can someone help? The

  • 0

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
                       };
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:34:47+00:00Added an answer on May 25, 2026 at 3:34 am

    The data provider used to translate the LINQ code to SQL doesn’t understand ToShortDateString. Because of that, you can’t 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:

        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 {
                           city = o.city,
                           customersOrderRef = o.customersOrderRef,
                           date = (o.actualDelivery ?? o.plannedDelivery),
                           date1 = (o.actualCease ?? o.actualCease),
                           number = o.number,
                           ordered = o.ordered,
                           postCode = o.postCode,
                           status = s.status,
                           stockCode = o.stockCode,
                           UpdatedByAccount = o.UpdatedByAccount
                       }).ToList()
                         .Select(x => new DataLayer.OrderStatusItem {
                           city = x.city,
                           customersOrderRef = x.customersOrderRef,
                           date = x.date,
                           date1 = x.date1,
                           number = x.number,
                           ordered = x.ordered.DateTime.ToShortDateString(),
                           postCode = x.postCode,
                           status = x.status,
                           stockCode = x.stockCode,
                           UpdatedByAccount = x.UpdatedByAccount
                       };
    

    BTW: There is another solution that produces shorter code:

        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 { o, s }).ToList()
                       .Select(x => new DataLayer.OrderStatusItem
                       {
                           city = x.o.city,
                           customersOrderRef = x.o.customersOrderRef,
                           date = (x.o.actualDelivery ?? x.o.plannedDelivery),
                           date1 = (x.o.actualCease ?? x.o.actualCease),
                           number = x.o.number,
                           ordered = x.o.ordered.DateTime.ToShortDateString(),
                           postCode = x.o.postCode,
                           status = x.s.status,
                           stockCode = x.o.stockCode,
                           UpdatedByAccount = x.o.UpdatedByAccount
                       };
    

    The difference between those two versions is that the first version only requests those columns from the database you need where as the second version will return all columns of the two tables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting an odd HTML validation error from this piece of JavaScript any help
Can someone please tell me where is the error in this code?, I use
Im getting this odd error: Any help would be great? This is the error:
I am getting an odd error: 2009-09-12 18:47:15.967 CraigsAlerts[10057:207] * -[UINavigationController popNavigationItemAnimated:]: unrecognized selector
I'm getting an odd error from my composite canvas component: An ActionScript error has
I'm getting an odd error with Google App Engine devserver 1.3.5, and Python 2.5.4,
I'm getting this odd error in the preg_match() function: Warning: preg_match(): Compilation failed: range
I'm getting an odd error when I try to push to a new remote
Attempting to build an interface and generics based graph and getting an odd error
i'm getting an error 'Object expected' for some odd reason due to jquery, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.