Skip to content

Instantly share code, notes, and snippets.

@Suchiman
Last active April 27, 2017 23:33
Show Gist options
  • Save Suchiman/209206eb2f9caeab15bc6e362d2e256d to your computer and use it in GitHub Desktop.
Save Suchiman/209206eb2f9caeab15bc6e362d2e256d to your computer and use it in GitHub Desktop.
var take = options.count > 0 ? options.count : 12;
var page = options.page > 0 ? options.page : 1;
var skip = take * (page - 1);
var analysis = _DBContext.Analysis
.Select(a => new
{
comment_count = _DBContext.Comments.Count(c => c.AnalysisID == a.AnalysisID),
created_at = a.CreatedAt,
description = a.Description,
game = new
{
patch = a.Game.Patch.Version,
title = a.Game.Title
},
id = a.AnalysisID,
matchup = new
{
players = a.Matchup.Players.Select(p => new
{
name = p.Character.Name
})
},
user_id = a.Reward.UserID,
title = a.Title,
updated_at = a.UpdatedAt,
user = a.User
})
.AsEnumerable()
.Select(a => new
{
a.comment_count,
a.created_at,
a.description,
a.game,
a.id,
a.matchup,
reward = a.user_id != null ?
new
{
user_id = a.user_id
} : null,
a.title,
a.updated_at,
a.user
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment