When trying to create this linq statement. I ran into the following error:
Unable to cast object of type ‘System.Data.Common.DataRecordInternal’
to type ‘System.Data.IDataReader’
This is what I’m doing per @SLaks promising answer.
List<TypeData> = reader.Cast<IDataReader>()
.Select(dr => new TypeData { Type = (string)dr["type"] })
.ToList();
Try
reader.Cast<DbDataRecord>orreader.Cast<IDataRecord>instead:IDataRecordInterface