-1

i need to read a collection within collection and return json result either my linq or feach?

from col1 in collection1 select new{}{col1.field1, col1.field2, }

Read collection2 in col1 and do sum of numeric field present for each row and return to json.

Rafay Zia Mir
  • 2,116
  • 6
  • 23
  • 49
user1480864
  • 1,455
  • 3
  • 16
  • 23

1 Answers1

0

If I've read and deciphered your question correctly, I think you are looking for:

var collectionOfSums = from col1 in collection1
                       select new {
                         SumOfField1 = field1.Sum(),
                         SumOfField2 = field2.Sum(),
                         ...
                         SumOfFieldN = fieldN.Sum()
                       };    

I am assuming that the field1, field2, ... fieldN are a known set. Then use whatever technology you prefer to JSON-ify collectionOfSums.

bluevector
  • 3,485
  • 1
  • 15
  • 18