c# - LINQ finding the highest frequency -
i trying find "most popular" game based on number of occurrences. wrote linq query below
var query = (from evt in events game in evt.eventgames group game game.gametypeid g select new {g.key, count = g.count()}).orderbydescending(x => x.count).firstordefault(); var gametype = repository.getrepository<gametype>().find(query?.key);
i realised querying twice game type has highest frequency.
is possible game type first query itself?
-alan-
yes, group gametype
instead of gametypeid
.
var gametype = (from evt in events game in evt.eventgames group game game.gametype g orderby g.count() descending select g.key) .firstordefault();
Comments
Post a Comment