I have this expression:
from comps in ctx.TblControls
join reviews in ctx.TblReviews on comps.Id equals reviews.ControlId
join tags in ctx.TblTags on comps.TagId equals tags.Id
join framework in ctx.TblFrameworks on comps.FrameworkId equals framework.Id
where comps.Guid == guid
select new
{
ratingTotal = ((ctx.TblReviews.Where(x => x.Rating == 5).Count() * 5) + (ctx.TblReviews.Where(x => x.Rating == 4).Count() * 4) + (ctx.TblReviews.Where(x => x.Rating == 3).Count() * 3) + (ctx.TblReviews.Where(x => x.Rating == 2).Count() * 2) + (ctx.TblReviews.Where(x => x.Rating == 1).Count() * 1)),
ratingValue = ctx.TblReviews.Where(x => x.Rating == 5).Count() + ctx.TblReviews.Where(x => x.Rating == 4).Count() + ctx.TblReviews.Where(x => x.Rating == 3).Count() + ctx.TblReviews.Where(x => x.Rating == 2).Count() + ctx.TblReviews.Where(x => x.Rating == 1).Count(),
reviews,
tags,
framework,
comps
}
return View(new { componentData = componentData.FirstOrDefault() });
and the result is that the expression is returning 2 rows because the "reviews" has two rows returning but i need the Select new {} to return one row with the data inside, where "reviews" has a count of 2.
I hope i explained this right, if i have not, let me know and ill include pictures.