尝试创建this linq语句时。我遇到了以下错误:无法将类型为“System.Data.Common.DataRecordInternal”的对象强制类型为“System.Data.IDataReader”
Unable to cast object of type 'System.Data.Common.DataRecordInternal' to type 'System.Data.IDataReader'
这是我每@SLaks promising answer做什么。
List<TypeData> = reader.Cast<IDataReader>()
.Select(dr => new TypeData { Type = (string)dr["type"] })
.ToList();
你可以发布你的'TypeData'类的代码结构? – jp2code
另外,看起来你正在设置TypeData obj = xxx.ToList()。 – jp2code