Пример #1
0
        /// <summary>
        /// Creates a <see cref="System.Data.DataTable"/> using the schema of <typeparamref name="T"/> and data from <paramref name="rows"/>.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="rows">Values for rows in the data table.</param>
        /// <returns>A <see cref="System.Data.DataTable"/> using the schema of <typeparamref name="T"/> and data from <paramref name="rows"/>.</returns>
        public static DataTable AsDataTable <T>(this IEnumerable <T> rows)
        {
            var dataTable = GetSchemaTable <T>();

            rows.Select(row => GetterDelegateCache <T> .ReadablePropertyNames
                        .Select(s => GetterDelegateCache <T> .Read(s, row))
                        .ToArray())
            .ToList()
            .ForEach(values => dataTable.Rows.Add(values));

            return(dataTable);
        }
 public object GetValue(int i)
 {
     return(GetterDelegateCache <T> .Read(i, _dataEnumerator.Current));
 }