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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:41:54+00:00 2026-05-13T09:41:54+00:00

I have two tables tblActionLog and tblLoginLog . This is tblActionLog : tblActionLog ————

  • 0

I have two tables tblActionLog and tblLoginLog.

This is tblActionLog:

tblActionLog
------------
ID (int)
Happened (DateTime)
...etc.

This is tblLoginLog:

tblLoginLog
-----------
ID (int)
LoginDate (DateTime)
...etc.

Now I want to have a GridView with information from both of these tables interleaved in eachother so that their separate date informations are sorted, e.g.:

LOG OF STUFF
-------------------------------
DATE        |  WHAT     
2009-09-09  | Anderson logged in.
2009-09-08  | Smith made an action.
2009-09-08  | Smith logged in.
2009-09-06  | Anna made an action.
2009-09-04  | Smith made an action.

I hope this makes it clear enough. I want to get all of this information in a single LINQ query (not necessarily one SQL query). Any help appreciated.

  • 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-13T09:41:55+00:00Added an answer on May 13, 2026 at 9:41 am

    You probably want to use Select() and Union() to collate the results.

    var query = context.Logins.Where( l => l.UserID == userID )
                              .Select( l => new { Date = l.Date, What = "logged in" } )
                      .Union( context.Actions.Where( a => a.UserID == userID )
                                              .Select( a => new { Date = a.Date, What = a.Action  } ))
                      .OrderBy( r => r.Date );
    

    Note: you may need to materialize each subquery (use ToList() or AsEnumerable()), but I think LINQ2SQL should be able to construct the UNION directly. Also, this is completely untested – typed straight into the answer editor and I didn’t check the signature of the Union method so you may need to adjust.

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

Sidebar

Related Questions

I have two tables and want to compare rows on sqlite like this table1
I have two tables in my database who looks like this: User: userid(int) username(varchar)
I have two tables on a webform. On a button click I want to
I have two tables: users and user_depts. Let's say (for this question) that users
I have two tables with this structure: Table one: ID Description Table two: ID
I have two tables CREATE TABLE table1 (id int primary key auto_increment,....); CREATE TABLE
I have two tables looking like this: A B id_attr value id id_attr value
I have two tables built like this (this is just a simplified and non-proprietary
I have two tables users and work_orders. Now I need to get work_orders results
I have two tables: User and Event in a many-to-many relationship. For this I

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.