For updating a post comment following code is written:
|
var post = await _ctx.Posts |
|
.Include(p => p.Comments) |
|
.FirstOrDefaultAsync(p => p.PostId == request.PostId, cancellationToken); |
For example, if the post has more than 2000 comments, This code will load all of them into memory.
While we need to update only one comment.
Wouldn't it be better to do it as this:
var post = await _ctx.Posts
.Include(p => p.Comments.Where(_ => _.CommentId == request.CommentId))
.FirstOrDefaultAsync(p => p.PostId == request.PostId, cancellationToken);
For updating a post comment following code is written:
CwkSocial/CwkSocial/CwkSocial.Application/Posts/CommandHandlers/UpdatePostCommentHandler.cs
Lines 26 to 28 in 6087579
For example, if the post has more than 2000 comments, This code will load all of them into memory.
While we need to update only one comment.
Wouldn't it be better to do it as this: