55using System . Collections ;
66using System . Collections . Concurrent ;
77using System . Collections . Generic ;
8+ using System . Data . Entity ;
89using System . Diagnostics ;
910using System . IO ;
1011using System . Linq ;
@@ -114,7 +115,12 @@ public List<Account> GetTopPlayers(int count)
114115 {
115116 using ( ZkDataContext db = new ZkDataContext ( ) )
116117 {
117- laddersCache = db . Accounts . OrderByDescending ( x => x . AccountRatings . Where ( r => r . RatingCategory == category ) . Select ( r => r . Elo ) . DefaultIfEmpty ( - 1 ) . FirstOrDefault ( ) ) . Take ( count ) . ToList ( ) ;
118+ laddersCache = db . Accounts
119+ . Include ( a => a . Clan )
120+ . Include ( a => a . Faction )
121+ . OrderByDescending ( x => x . AccountRatings . Where ( r => r . RatingCategory == category ) . Select ( r => r . Elo ) . DefaultIfEmpty ( - 1 ) . FirstOrDefault ( ) )
122+ . Take ( count )
123+ . ToList ( ) ;
118124 }
119125 }
120126 if ( laddersCache . Count < count )
@@ -123,7 +129,12 @@ public List<Account> GetTopPlayers(int count)
123129 using ( ZkDataContext db = new ZkDataContext ( ) )
124130 {
125131 List < int > retIDs = topPlayers . Take ( count ) . ToList ( ) ;
126- laddersCache = db . Accounts . Where ( a => retIDs . Contains ( a . AccountID ) ) . OrderByDescending ( x => x . AccountRatings . Where ( r => r . RatingCategory == category ) . Select ( r => r . Elo ) . DefaultIfEmpty ( - 1 ) . FirstOrDefault ( ) ) . ToList ( ) ;
132+ laddersCache = db . Accounts
133+ . Where ( a => retIDs . Contains ( a . AccountID ) )
134+ . Include ( a => a . Clan )
135+ . Include ( a => a . Faction )
136+ . OrderByDescending ( x => x . AccountRatings . Where ( r => r . RatingCategory == category ) . Select ( r => r . Elo ) . DefaultIfEmpty ( - 1 ) . FirstOrDefault ( ) )
137+ . ToList ( ) ;
127138 }
128139 }
129140 return laddersCache . Take ( count ) . ToList ( ) ;
@@ -140,7 +151,11 @@ public List<Account> GetTopPlayers(int count, Func<Account, bool> selector)
140151 {
141152 foreach ( var pair in sortedPlayers )
142153 {
143- Account acc = db . Accounts . Where ( a => a . AccountID == pair . Value ) . FirstOrDefault ( ) ;
154+ Account acc = db . Accounts
155+ . Where ( a => a . AccountID == pair . Value )
156+ . Include ( a => a . Clan )
157+ . Include ( a => a . Faction )
158+ . FirstOrDefault ( ) ;
144159 if ( playerRatings [ acc . AccountID ] . Rank < int . MaxValue && selector . Invoke ( acc ) )
145160 {
146161 if ( counter ++ >= count ) break ;
0 commit comments