Long story short, I've been trying to write a LINQ query for the following statement:
DECLARE @id int
SET @id = 3
SELECT slp.LearningProgressID, a.LastUpdatedUTC AS PendingTestDate, a.TimeZoneLookupID
FROM
(
SELECT userid, learningmoduleid, MAX(instancenumber) AS MaxInstance
FROM studentlearningprogress
WHERE learningmoduleid = @id
GROUP BY userid, learningmoduleid
) AS LatestProgress
INNER JOIN studentlearningprogress slp
ON slp.userid = latestprogress.userid
AND slp.learningmoduleid = latestprogress.learningmoduleid
AND slp.instancenumber = latestprogress.MaxInstance
INNER JOIN studentlearningprogressactivity a
ON a.studentlearningprogressid = slp.learningprogressid
WHERE slp.studentlearningprogressstatusid = 4
AND a.newstudentlearningprogressstatusid = 4
I've been unsuccessful getting even the subquery of LatestProgress to return anything. I am getting a Security Exception (which is odd). Is this even possible in LINQ or do I have to use a derived table with dynamic relations to get the result set I'm looking for?
Self-Servicing, 2.6, VB.NET