Include style
in your group, then reference orderItem
and style
in your select
:
var orderitems =
(from orderItem in Order_ProductItems
join style in Products_Styles on orderItem.Style equals style.Index
where orderItem.SalesOrderID == 123
group new { orderItem, style } by orderItem.FrameNo into grp
select new
{
FrameNo = grp.Key,
Count = grp.Select(x => x.orderItem.FrameNo).Count(),
TotalCost = grp.Sum(x => x.orderItem.CostPrice),
OverAllWidth = grp.Single(x => x.orderItem.HardwareType == 3).OverallHeight,
Name = grp.Select(x => x.style.Name).First(),
ImagePath = grp.Select(x => x.style.External_Image_Path).First()
};
You may have to adjust this to suit your needs, and it may not compile exactly as-is since I don't have an environment set up to test it in, but it should give you a general idea.