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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:28:15+00:00 2026-05-26T17:28:15+00:00

I got a local List<DateInterval> where DateInterval is: internal class DateInterval{ public DateTime StartDate

  • 0

I got a local List<DateInterval> where DateInterval is:

internal class DateInterval{
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
}

I want to get all the events on the database that matches at least one of the DateInterval.

Ideally I’ll do something like:

var query = from _event in db.GetTable<Event>()
            where dates.Any(d => d.StartDate <= _event.Date && d.EndDate > _event.Date)
            select _event;

But I get the following exception:

Local sequence cannot be used in LINQ to SQL implementation of query operators except     the Contains() operator

Since the .Contain() method only accept exact results instead of timestamps, is there a way to achieve the desired results?

  • 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-26T17:28:16+00:00Added an answer on May 26, 2026 at 5:28 pm

    Your basic option here is to materialize the query from the database and then perform the comparison against the list in memory.

    var query = yourSqlQuery.AsEnumerable() // forces* evaluation
                            .Where(...) // happens in memory 
    

    Obviously, the more filtering you can perform at the DB in order to pull less results into memory, the better, but in this case, your options are limited.

    var query = db.GetTable<Event>().AsEnumerable().Where(event => dates.Any(...)); 
    

    *The evaluation is still deferred until you use the results of the query, but the filtering from the additional Where will happen in memory, the portion before AsEnumerable() will occur at the database.

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

Sidebar

Related Questions

I want to use XPath to get a list of the names of all
I've got a public class, which implements Serializable, that is extended by multiple other
After saved upload file, i got local url of this file, how i convert
I've got a local application (which I didn't write, and can't change) that talks
So I've got a local repository with two branches: master and shop . I've
Ive got a url: http://dev.local/foodies/view?id=bluedaniel and ive got in my bootstrap: protected function _initRoute()
I've got an old classic ASP site that connects to a local sql server
I've got a ASP.NET site that's located on a local server (MY_SERVER). And one
I've got a HTML/JS (YUI framework) photo-organizer that needs access to the local FS.
I've got a flex/air app I've been working on, it uses a local sqlite

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.