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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:40:22+00:00 2026-06-06T01:40:22+00:00

I was writing a simple LINQ query which compares rows of a table with

  • 0

I was writing a simple LINQ query which compares rows of a table with itself. Simply put, there are two datagrids on a form, the first one shows some rows and the second one is filled whenever a row is selected in the first grid with the following condition:

Find those rows that have the same code as the selected and their reception time differs less than 30 second (I mean the reception time of shown rows in the second grid must be sooner than reception time of selected row).

I have written the following code:

    Call_Log selected = (Call_Log)dataGrid1.SelectedItem;
    var subData = from cLog in callLog
                  where cLog.Check_Create == 1 &&
                  EntityFunctions.DiffSeconds(selected.ReceptionTime,cLog.ReceptionTime) < 30 &&
                  selected.CustomerCode == cLog.CustomerCode &&
                  selected.CalledID == cLog.CalledID &&
                  selected.ID != cLog.ID
                  select cLog;

But it returns some rows which differ more than 30 seconds with the selected row. How can I fix this?

Comment:

In the above code, I need to have those rows (cLog) which differ less than 30 seconds from selected row.

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-06T01:40:24+00:00Added an answer on June 6, 2026 at 1:40 am

    In case of DiffSeconds return negative value more than 30 seconds, your validation return true.

    try compare after taking Math.abs as

    Math.Abs(EntityFunctions.DiffSeconds(selected.ReceptionTime,cLog.ReceptionTime)‌​) < 30
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to linq and having trouble writing two simple queries. For some reason,
I'm writing a simple LINQ to XML query. As often, the some elements might
Instead of writing a linq query, is there a way I can just do
I got one big question. I got a linq query to put it simply
I'm writing a simple movie database which has a three tier stack of service
I'm writing a simple search query for my Entity Framework application. I need to
Hi I am looking for best method for writing Dynamic LINQ query. I have
I am writing a simple XML file parser using LINQ to XML. I want
What is the benefit of writing a custom LINQ provider over writing a simple
I am writing simple program for my Ubuntu 10.04. I want to see which

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.