// Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Linq; // ReSharper disable once CheckNamespace namespace System.Collections.Generic; public static class EnumerableExtensions { public static IReadOnlyList>> ToTable(this IEnumerable> source) { var listOfRows = new List>>(); foreach (var row in source) { var dict = new List>(); listOfRows.Add(dict); foreach (var (fieldName, fieldValue) in row) { dict.Add( new KeyValuePair( fieldName, fieldValue)); } } return listOfRows; } public static IEnumerable>>> ToTables(this IEnumerable>> source) => source.Select(x => x.ToTable()); }