Hi Folks,
i've got the following code, which compiles but doesn't retrieve the correct results.
I'm trying to retrieve all the Banned log entries for people who have been recorded at cheating on a gaming server.
The database (in this case, two IList tables) has two simple tables.
- GameFiles : the game which has a log file .. which we parse.
- LogEntries : an individual entry in a log file. Each game file has mother-bucket load of log entries.
So this is a simple 1 to many relationship.
Currently it's retrieving all the results for GameType.BattleField2, but not for GameType.CallOfDuty4. I have confirmed that the IList gameFiles does contain some data for GameType.BattleField2 and for GameType.CallOfDuty4. I have also confirmed that each of those files has log entries.
So, can someone have a look at this linq and tell me what i've done wrong?
public IList<LogEntry> BannedEntries(GameType? gameType)
{
var query = from l in _logEntryRepository.GetLogEntries()
join g in _gamefileRepository.GetGameFiles()
on l.GameFileId equals g.GameFileId into JoinedResult
from x in JoinedResult.DefaultIfEmpty()
select new
{
LogEntry = l,
GameFile = x
};
if (gameType.HasValue)
{
query = from q in query
where q.GameFile.GameType == gameType
select q;
}
// Now retrieve only LogEntries.
return (from q in query
where q.LogEntry.EventType == EventType.BannableViolation
select q.LogEntry)
.ToListIfNotNullOrEmpty();
}