Esempio n. 1
0
        public static IEnumerable <IEnumerable <(TableColumn column, object value)> > EnumerateRows(this ITableData data, params string[] columnNames)
        {
            if (data is null)
            {
                throw new ArgumentNullException(nameof(data));
            }
            var columns = (columnNames?.Length > 0 ?
                           data.Definition.ColumnsSynchronized.WithNames(true, columnNames) :
                           data.Definition.ColumnsSynchronized).
                          ToArray();

            data.Reset();
            while (data.Read())
            {
                yield return(columns.Select(column =>
                {
                    int ordinal = data.GetOrdinal(column.DataSetColumn);
                    object value = data.GetValue(ordinal);
                    return (column, value);
                }));
            }
        }