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 8459897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:27:20+00:00 2026-06-10T13:27:20+00:00

I have defined the following Model public class TodayOrder { public string ID_ORIG {

  • 0

I have defined the following Model

  public class TodayOrder
{
    public string ID_ORIG { get; set; }
    public string PART_ID { get; set; }
    public string PART_DEX { get; set; }
    public double TimeSecs { get; set; }
 }

and now I am trying to populate a List using the following Linq expression:

var todaysOrders = DCC.vw_ORD_GP_volumes_lastSets
 .Where(a => a.ID_ORIG == id_orig.ToUpper() && 
             a.PART_ID == Part.ToUpper())
 .Select(a => 
     new TodayOrder{ 
         ID_ORIG = a.ID_ORIG, 
         PART_ID = a.PART_ID, 
         PART_DEX = a.PART_DEX,  
         TimeSecs = a.ReqTime.GetValueOrDefault().TotalSeconds });

List<TodayOrder> lst = todaysOrders.ToList();

where ReqTime is of type TimeSpan?.

The problem is that at runtime I am getting an error Value has no literal in SQL: 00:00:00 – looks like there is a problem with the TimeSpan.

 Line 72:                     });
 Line 73:   ERROR>              lst = todaysOrders.ToList();
 Line 74:  
 [InvalidOperationException: Value has no literal in SQL: 00:00:00]
  System.Data.Linq.SqlClient.Visitor.FormatValue(Object value) +584911
  System.Data.Linq.SqlClient.Visitor.VisitValue(SqlValue value) +32

In facts, if I comment out the line setting the property TimeSecs everything is working fine.

What would be the right approach to instantiate the TodayOrder class instances?

  • 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-06-10T13:27:22+00:00Added an answer on June 10, 2026 at 1:27 pm

    The problem is that Linq-to-Sql treis to translate the expression a.ReqTime.GetValueOrDefault().TotalSeconds to sql but it fails.

    You can solve it by evaluating the query with a ToArray() before the select and do the select on the client side:

    var todaysOrders = DCC.vw_ORD_GP_volumes_lastSets
     .Where(a => a.ID_ORIG == id_orig.ToUpper() && 
                 a.PART_ID == Part.ToUpper())
     .ToArray()
     .Select(a => 
         new TodayOrder{ 
             ID_ORIG = a.ID_ORIG, 
             PART_ID = a.PART_ID, 
             PART_DEX = a.PART_DEX,  
             TimeSecs = a.ReqTime.GetValueOrDefault().TotalSeconds });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following model defined in .NET: Public Class Request <Key()> Public Property
I have the following data model class defined: @PersistenceCapable public class TestSerializableModelObj { @Persistent(serialized=true,
All, i have the following model defined, class header(models.Model): title = models.CharField(max_length = 255)
I have the following java model class in App Engine: public class Xyz ...
Given the classes: public class Person { public string Name { get; set; }
I have defined a model class: public class MyObject { ... } In my
I have the following collection contract defined: [CollectionDataContract(Name = Centres)] public class Centres :
I have following model class in my application: public class Dispute { public long
I have the following unit test defined to test my model binder: [TestMethod] public
I have a model defined as public class Department { [ScaffoldColumn(false)] public object Id

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.