有一个如下IAsyncEnumerable泛型类型的对象
IAsyncEnumerable<BlogComment> blogComments = await _blogCommentService.GetCommentsByPostId(Id);
将IAsyncEnumerable类型转换为ICollection类型有如下方法
方法1:强制转换
blogPost.BlogComments = (ICollection<BlogComment>)blogComments;
方法2:使用List类型进行转换
blogPost.BlogComments = await blogComments.ToList();