I want to cast reader from mysqldatareader to list of specific object. So i use the function cast but it doesn't work, i have an exception. enter image description here
This is the class of objectenter image description here
I want to cast reader from mysqldatareader to list of specific object. So i use the function cast but it doesn't work, i have an exception. enter image description here
This is the class of objectenter image description here
Copyright © 2021 Jogjafile Inc.
You can't cast a
MySqlDataReader
to aList<T>
. You should use the reader to read the records from the database and create aKeyError
object for each record that you add to the list. Something like this:The
MySqlDataReader
class has methods for getting the value of a specified column in the result set as any of the primitive C# data types: https://dev.mysql.com/doc/dev/connector-net/8.0/html/T_MySql_Data_MySqlClient_MySqlDataReader.htm