I'm creating a web application using MVC that allows users to edit existing records, and these are stored in the database as a new record that references the very first instance of said record.
There's a column called "OriginalID" so when a video is edited, the edit has a higher ID but can always be linked back using the "OriginalID" column and the below SQL statement will return the latest data for each Video.
I want to achieve something like the below but using LINQ:
SELECT Title, Genre, Price, PegiCert, Release, Desc
FROM video vid
WHERE vid.id = ( SELECT TOP 1 vid2.id
FROM video vid2
WHERE ISNULL(vid2.originalid, vid2.id) = ISNULL(vid.originalid, vid.id)
ORDER BY id DESC )
I want to return a list of Video but only the latest edits.
IQueryable<Video> _videos;
_videos = // LINQ statement
return _videos.ToList<Video>();
Is this possible?