locked
Return multiple parameters from a list collection based on amalgamated function RRS feed

  • Question

  • User1909155429 posted

    pr = From p In product.Values Group p.Price By Key = p.Email Into Group = Group _
                     
    Select New With {.Email = Key, .Price = Group.Sum()}

    i have the following query statement and want to retrieve the ContactID parameter value inaddition to the Email  and Price parameters ?

    return the distinct Email and ContactID values together with the total price for each distinct parameter

    Saturday, February 8, 2014 3:01 PM

All replies

  • User1140095199 posted

    Hi,

    Try the code below. Though I don't know the complete structure of the table you can refer to the following code and modify as per your need.

                var pr = from p in db.ProductTable
                         group p by p.ContactID into datagroup
                         select new
                         {
                             contactID = datagroup.Key,
                             email = datagroup.FirstOrDefault().Email,
                             price = datagroup.Sum()
                         };

    Hope it helps!
    Best Regards!

     

     

    Wednesday, February 12, 2014 3:28 AM
  • User1909155429 posted

    Hello,

    Thanks for the code, but i am using a list collection  Product.values for the datasource !

    error exception states datagroup is not accesible in this context !

    Wednesday, February 12, 2014 2:12 PM