将dataReader转换为Dictionary

hel*_*boy 5 linq dictionary datareader

我尝试使用LINQ将一行转换为Dictionary(fieldName - > fieldValue)

return Enumerable.Range(0, reader.FieldCount)
                 .ToDictionary<string, object>(reader.GetName, reader.GetValue);
Run Code Online (Sandbox Code Playgroud)

但是我收到了错误消息:

实例参数:无法转换'System.Collections.Generic.IEnumerable<int>''System.Collections.Generic.IEnumerable<string>'

怎么纠正这个?

Tho*_*que 15

return Enumerable.Range(0, reader.FieldCount)
                 .ToDictionary(
                     i => reader.GetName(i),
                     i => reader.GetValue(i));
Run Code Online (Sandbox Code Playgroud)