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.
You probably want to use Select() and Union() to collate the results.
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.