I have two tables which, to simplify, look like this:
TheFiles
FileID | UserID
23 | 342
53 | 352
TheData
UserID | DateCreated
352 | 7/22/2014
245 | 7/25/2014
589 | 7/28/2014
I'm looking to return a nullable int that represents the latest UserID from the table TheData that's not in the table TheFiles. So for example, with this sample data, the return value would be 589 because it's the latest entry in TheData and it's not in the table TheFiles.
I'm having some trouble on the where when there's no data. This is what I have:
var TheNullableInt = (from d in MyDC.TheData
where d.UserID doesn't exist in MyDC.TheFiles
orderby d.DateCreated descending
select d.UserID).FirstOrDefault();
I'm using linq-to-SQL. How can I do the where clause?