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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:37:39+00:00 2026-06-11T17:37:39+00:00

I have a database with about 3 milion records, each record has id (int,

  • 0

I have a database with about 3 milion records, each record has id (int, primary key), uniqueNumber(int) and updateTime(string).

uniqueNumber can belong to several records.
updateTime represents the time of the day the record was updated such as 14:33:42

EDIT: the records are ordered by update time.

I want to let the user define a uniqueNumber and an interval. Then I want to query the DB to get all the records belongs to that uniqueNumber where their updateTime is equal to a variable which it’s value is increasing by interval each time the where condition is true.

For example, I want something like this: (there is no DB used in this example)

    string currentTime = "12:25:00";
    int interval = 2;

    public void LinqExample()
    {
        string[] arr = new string[4] { "12:23:00", "12:26:00", "12:27:00", "12:28:00"};

        var query = from c in arr
                    where c.Replace(":", "").CompareTo(currentTime.Replace(":", "")) > 0 && Inc()
                    select c;

        // query's output is: "12:26:00", "12:28:00"
    }

    private bool Inc()
    {
        currentTime = DateTime.Parse(currentTime).AddMinutes(interval).ToLongTimeString();
        return true;
    }

is my code is the proper way to do this?

thanks!

  • 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-11T17:37:40+00:00Added an answer on June 11, 2026 at 5:37 pm

    It seems that code you want if it exists require generating SQL query with CURSOR over your table by EF. However as I quess, EF never produces code with cursors, therefore you cannot solve your problem using LINQ. IMHO the only way to do this is to write table-valued function like this

    CREATE FUNCTION GetTimesByUniqueNumberWithIntervalAndCondition
    (
        @interval int, @uniqueNumber int,@currentTime time
    )
    RETURNS 
    @Times TABLE 
    (
        t char(10)
    )
    AS
    BEGIN
        DECLARE timeCursor CURSOR LOCAL FAST_FORWARD READ_ONLY FOR
        SELECT updateTime FROM Table2 WHERE uniqueNumber = @uniqueNumber
        ORDER BY updateTime 
    
        DECLARE @t char(10);
    
        OPEN timeCursor
        FETCH NEXT FROM timeCursor INTO @t;
    
        WHILE @@FETCH_STATUS = 0
        BEGIN
            IF 
                1 = 1 -- place your condition here
            BEGIN
                INSERT @Times(t) VALUES(@t)
                SET @currentTime = DATEADD(MINUTE,@interval,CAST(@t AS time))
            END
    
            FETCH NEXT FROM timeCursor INTO @t;
        END
    
        CLOSE timeCursor
        DEALLOCATE timeCursor
    
        RETURN 
    END
    GO
    

    and query against this function every time you need the selection.

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

Sidebar

Related Questions

I have about 28 million records to import into a mySql database. The record
I have a table that has about 1/2 million records in it. Each month
So we have a database column that can contain just about anything. Unicode, numbers,
I have a very little idea about what database file system is. Can somebody
I have a very large database with about 120 Million records in one table.I
In the database table, I have about 1 million record. In the number field
I have two massive tables with about 100 million records each and I'm afraid
I have a database that is currently using AES 128. The database has about
I have an Android Service that accesses the database about once per minute. Is
I have a Database that contains data about articles , structures and manufacturers .

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.