我有以下Post类:查找出来,如果用户喜欢具体的意见
public class Post
{
public string Id {get;set;}
public string Content {get;set;}
public IList<Comment> Comments {get;set;}
}
public class Comment
{
public int OrderNumber {get;set;} //kind of CommentId
public string AuthorId {get;set;}
public string Text {get;set;}
public IList<string> Voters {get;set;} //Ids of users who liked the post
}
可能有成千上万的喜好为每个评论的,但我需要在客户机上只显示他们的数量,所以我创建以下索引:
Map = posts => from post in posts
select new {
Id = post.Id,
Content = post.Content,
Comments = post.Comments.Select(x =>
new CommentProjection {
AuthorId = x.AuthorId,
Text = x.Text,
VotersCount = x.VotersCount
}),
};
问题是我需要突出显示那些用户已经喜欢的评论。有没有办法修改上述索引以将这些信息添加到查询结果中?
好像它是很多网站的一个问题。有些人根本没有这个功能,有些人只是在放置它后立即想象你,但如果你刷新一个页面,没有具体的东西会显示出来。 – SiberianGuy 2015-03-10 10:23:50