Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要读取集合中的集合并返回我的 linq 或 feach 的 json 结果?
from col1 in collection1 select new{}{col1.field1, col1.field2, }
读取 collection2col1并对每行存在的数字字段求和,然后返回json。
col1
json
如果我已正确阅读并解读了您的问题,我认为您正在寻找:
var collectionOfSums = from col1 in collection1 select new { SumOfField1 = field1.Sum(), SumOfField2 = field2.Sum(), ... SumOfFieldN = fieldN.Sum() };
我假设field1, field2, ...fieldN是已知集合。然后使用您喜欢的任何技术来JSON-ify collectionOfSums。
field1
field2
fieldN
JSON
collectionOfSums