Skip to content

Instantly share code, notes, and snippets.

@ngohungphuc
Created August 2, 2019 08:55
Show Gist options
  • Save ngohungphuc/aa8357221e87567ccbe6b792c505726c to your computer and use it in GitHub Desktop.
Save ngohungphuc/aa8357221e87567ccbe6b792c505726c to your computer and use it in GitHub Desktop.
public class Repository
{
private readonly AppDbContext _appDbContext;
public Repository(AppDbContext appDbContext)
{
_appDbContext = appDbContext;
}
public IQueryable<Post> GetPostQuery()
{
return _appDbContext.Posts.AsQueryable();
}
public async Task<IEnumerable<Comment>> GetCommentByPostId(int postId)
{
return await _appDbContext.Comments.Where(x => x.PostId == postId).ToListAsync();
}
public IQueryable<Comment> GetCommentQuery()
{
return _appDbContext.Comments.AsQueryable();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment