Can someone help me come up with a robust way to write this below. I dont like the linq below.
Dictionary<string, List<DetailRoot>> colorDataList = colorReporter.GetSiteData();
var userSessionMetrics = (from DetailRoot o in colorDataList.First().Value
group o by (o.ColorGuid, o.ColorId) into t
select new
{
UniqueID = t.Key,
TotalItemsPurchased = t.Select(x => x.Details.Select(y => y.EventType == "Purchase")).Sum(z => z.Count()),
ColorPurchases = t.Select(x => x.Details.Select(y => y.EventType == "Purchase")).Count() > 0 ? 1 : 0,
ColorItemsCheckouts = t.Select(x => x.Details.Select(y => y.EventType == "Checkout")).Sum(z => z.Count()),
ColorCheckouts = t.Select(x => x.Details.Select(y => y.EventType == "Checkout")).Count() > 0 ? 1 : 0,
TotalRevenue = t.Select(x => x.Details.Where(y => y.EventType == "Purchase").Sum(z => z.Revenue))
}).ToList();