Browse Source
Merge pull request #8588 from abpframework/enisn/rel-4.3/cms-kit/fix-comments-mongodb-query
CmsKit - Fix MongoDb Query for Comment details
pull/8622/head
İlkay İlknur
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
16 additions and
8 deletions
-
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs
|
|
|
@ -23,14 +23,18 @@ namespace Volo.CmsKit.MongoDB.Comments |
|
|
|
|
|
|
|
public async Task<CommentWithAuthorQueryResultItem> GetWithAuthorAsync(Guid id, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
var dbContext = await GetDbContextAsync(); |
|
|
|
var commentQueryable = await GetMongoQueryableAsync(cancellationToken); |
|
|
|
var userQueryable = dbContext.Collection<CmsUser>(); |
|
|
|
|
|
|
|
var query = from comment in (await GetMongoQueryableAsync(cancellationToken)) |
|
|
|
join user in (await GetDbContextAsync(cancellationToken)).CmsUsers on comment.CreatorId equals user.Id |
|
|
|
where id == comment.Id |
|
|
|
select new CommentWithAuthorQueryResultItem |
|
|
|
{ |
|
|
|
Comment = comment, |
|
|
|
Author = user |
|
|
|
}; |
|
|
|
join user in (await GetDbContextAsync(cancellationToken)).CmsUsers on comment.CreatorId equals user.Id |
|
|
|
where id == comment.Id |
|
|
|
select new |
|
|
|
{ |
|
|
|
Comment = comment, |
|
|
|
Author = user |
|
|
|
}; |
|
|
|
|
|
|
|
var commentWithAuthor = await query.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); |
|
|
|
|
|
|
|
@ -39,7 +43,11 @@ namespace Volo.CmsKit.MongoDB.Comments |
|
|
|
throw new EntityNotFoundException(typeof(Comment), id); |
|
|
|
} |
|
|
|
|
|
|
|
return commentWithAuthor; |
|
|
|
return new CommentWithAuthorQueryResultItem() |
|
|
|
{ |
|
|
|
Comment = commentWithAuthor.Comment, |
|
|
|
Author = commentWithAuthor.Author |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<List<CommentWithAuthorQueryResultItem>> GetListAsync( |
|
|
|
|