I have a SQL Server table that contains the following fields:
- SessionId (guid)
- Message (varchar)
- Timestamp (datetime)
What I need to do is to pull out the FIRST record for EACH SessionId using LINQ to SQL (ideally as a lambda, but query syntax would be useful)
It’s relatively simple to do this with t-SQL….
SELECT al.Message, al.SessionId, al.Timestamp
FROM AppLog AS al
WHERE al.Timestamp =
(select MIN(al2.Timestamp) from ApplicationLog as al2 where al2.SessionId = al.SessionId)
I’ve tried to do the same with a Lambda query (using joins) but it’s just not working…
Any/all help will be much appreciated.
Thanks in advance
Griff
I don’t know if I’m being simplistic– but if this is one table, then this should work?