我有以下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