I have sql as below
SELECT Q.MaterialID AS MaterialID, Q.ProductID AS ProductID, QB.Quantity AS Quantity,
Q.ParameterID AS ParameterID, SUM((Q.ParameterValue * Q.Quantity)/Q.TotalTonnes) AS ParameterValue
FROM @Quality Q
INNER JOIN @QuantityBreakdown QB
ON ((Q.MaterialID = QB.MaterialID) OR (Q.MaterialID IS NULL AND QB.MaterialID IS NULL))
AND ((Q.ProductID = QB.ProductID) OR (Q.ProductID IS NULL AND QB.ProductID IS NULL))
GROUP BY Q.MaterialID, Q.ProductID, ParameterID, QB.Quantity
conversion to LINQ..... struck at ???
var enumerable = from final in (from q in qualities
from qb in quantityBreakDowns
where q.ProductID == qb.ProductID && q.MaterialID == qb.MaterialID
select new
{
q.MaterialID,
q.ProductID,
q.ParameterID,
qb.Quantity,
ParameterValue = ((q.ProductID*q.Quantity)/q.TotalTonnes)
}
)
group final by new
{
final.MaterialID,
final.ProductID,
final.ParameterID,
???
}
into finalresult select finalresult;
Is there some other good way to do this.
Thanks