hello

LINQ group by sum


var
attributeTotalValues = (from a in objValue group a by new { a.ProductTypeID, a.AttributeCode } into b select new { ProductTypeID = b.Key.ProductTypeID, AttributeCode = b.Key.AttributeCode, TotalAttributeValue = b.Sum(a => a.AttributeValue.ToDecimal()) }); var objValue = (from a in LinqMetaData.PMExtendAttribute join b in LinqMetaData.PMProjectProductUnit on new { RefRecordID = a.RefRecordID, RefTable = a.RefTable, RecordStatus = a.RecordStatus } equals new { RefRecordID = b.ProjectProductUnitID, RefTable = "PM_ProjectProductUnit", RecordStatus = "Active" } where b.RecordStatus != "Inactive" && b.ProjectID == intProjectID && ids.Contains(b.ProjectProductUnitID) select new { ProductTypeID = b.ProductTypeID, ProjectProductUnitID = b.ProjectProductUnitID, AttributeCode = a.AttributeCode, AttributeValue = a.AttributeValue });

 

posted @ 2013-03-20 11:01  B追风少年  阅读(329)  评论(0编辑  收藏  举报

hello too