We are building a forum type web application, and we are tring to make the answers with most likes (and most dislikes) look different. The Answer entity has a Reactions property (list of reactions) that include likes and dislikes (those are differentiated with a boolean property, true for like, false for dislike). Is there a way to obtain the answer with most likes, and the answer with most dislikes, with a LINQ query directly? or we have to make a method that solves it?
EDIT: I have only one entity “Reactions” That represents both Likes and Dislikes. The only difference between the two of them, is a boolean property set on true for likes, and false on dislikes
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
EDIT: Based on Sajid’s comment, the query was simplified:
reactions.Where(liked => Liked.IsLike && (liked.id = 123)).Count()
reactions.Count(liked => liked.IsLike && liked.id == 123)