Removing values from a returned linq query

Posted by Diver D on Stack Overflow See other posts from Stack Overflow or by Diver D
Published on 2010-03-14T18:48:03Z Indexed on 2010/03/14 18:55 UTC
Read the original article Hit count: 232

Filed under:

HI there I am hoping for some help with a query I have.

I have this query

         var group =
              from r in CustomerItem
              group r by r.StoreItemID into g
              select new { StoreItemID = g.Key, ItemCount = g.Count(), ItemAmount = Customer.Sum(cr => cr.ItemAmount),RedeemedAmount = Customer.Sum(x => x.RedeemedAmount) };

I am returning my results to a list so I can bind it listbox.

I have a property called EntryType which is an int. There are 2 available numbers 1 or 2

Lets say I had 3 items that my query is working with

2 of them had the EntryType = 1 and the 3rd had EntryType2. The first records had a ItemAmount of 55.00 and the 3rd had a ItemAmount of 50.00

How can I group using something simlar to above but minus the ItemAmount of 50.00 from the grouped amount to return 60.00?

Any help would be great!!

© Stack Overflow or respective owner

Related posts about LINQ