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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:46:16+00:00 2026-06-07T12:46:16+00:00

I have, what I thought was a pretty straight-forward query. In normal Sql this

  • 0

I have, what I thought was a pretty straight-forward query.

In normal Sql this would read:

SELECT    [column names]
FROM      agentscheduledetail
WHERE     (date = '2012-07-04') AND 
           (
            exception = 'Break (No Sign Off)' OR
            exception = 'Break' OR
            exception = 'Break (Signed Out)'
           )

This returns approx 900 records.

However, when I try to enter this into my controller, I end up with around 300,000 records – so I think my AND and ORs are not working. I’ve tried Linqer, but can’t get it to work (I’m aware this may not be actual LINQ but the equivalent query in VS – if there is a linq version… I’d be grateful for that too if possible).

My controller query is:

        var dte = DateTime.Today;

        return View(db.agentscheduledetails.Where
           (
            d => d.date == dte && d.agentName.StartsWith("ta") && 
             (
              d.exception == "Break (No Sign Off)" || 
              d.exception == "Break" || 
              d.exception == "Break (Signed Out)"
             )
            ).ToList()
           );

Can anyone either a) let me know where I’m going wrong with my && || (and/or), or b) is there a way of stepping through the code in VS, to see what the above query translates to in normal SQL so I can try to figure out where I’m going wrong?

Thanks for any help,

Mark

  • 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-07T12:46:18+00:00Added an answer on June 7, 2026 at 12:46 pm

    The following is perhaps a simplified version of what you are trying to do, also your LINQ contains an additional statement compared to the SQL where it is comparing the agent name?

    var currentDate = DateTime.Today;
    var exceptionTypes = new List<string>() { "Break (No Sign Off)", 
                                              "Break", "Break (Signed Out)" };
    
    db.agentscheduledetails.Where(d => d.date == currentDate && 
                                               exceptionTypes.Contains(d.exception));
    

    One thing that you could try is getting hold of a copy of LinqPad, this will let you run your LINQ statement against a database and will show you what the generated SQL statement is.

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

Sidebar

Related Questions

Thought this would be pretty straight forward, but my value is remaining the same
I'm new to AutoFac, but I thought this would be pretty straight forward. I've
I thought this was pretty straight forward but I don't get the same results
I would have thought this one would be simple but I'm trying to change
I would have thought that this would be an easy thing to do, but
I came across this code on reddit . I would have thought that type
http://www.interact-sw.co.uk/iangblog/2004/04/26/yetmoretimedlocking Why is this line needed? System.GC.SuppressFinalize(tl.leakDetector); I would have thought the finalizer should
I thought this would be pretty straightforward, but I've been searching for a way
My question is hopefully pretty straight forward. Upon submitting my form, I would like
My situation is pretty straight forward. I have a server configured with max_allowed_packet set

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.