How to convert SqlDataReader into a user defined class?
-
Hi All, Can I covert the SqlDataReader into a user defined class? I will explain my doubt. I have a user defined class named 'Member' which contains the fields same as in the 'Member' table in database. Now I want to select the Members from database and converted to the array of class 'Member'. Is it possible? Is it will causes to overkill? Regards, Hogan
-
Hi All, Can I covert the SqlDataReader into a user defined class? I will explain my doubt. I have a user defined class named 'Member' which contains the fields same as in the 'Member' table in database. Now I want to select the Members from database and converted to the array of class 'Member'. Is it possible? Is it will causes to overkill? Regards, Hogan
You can create a method that received as a parameter an SqlDataReader object, and returns a Member array. There for each row in the database you create a new Member object, read the values and at the end return the array. Hope it helps.
There are 10 kinds of people: those who understand binary and those who don't
-
You can create a method that received as a parameter an SqlDataReader object, and returns a Member array. There for each row in the database you create a new Member object, read the values and at the end return the array. Hope it helps.
There are 10 kinds of people: those who understand binary and those who don't
Thank you for reply It require a loop. isn't it? I am worried about the performance. This member class in my business layer. Actually SqlDataReader is enough for the purpose. But I want to make it more slandered form Regards, Hogan
-
Thank you for reply It require a loop. isn't it? I am worried about the performance. This member class in my business layer. Actually SqlDataReader is enough for the purpose. But I want to make it more slandered form Regards, Hogan
Yes, you need a loop. I gave you a solution to a problem, though i would rather work with SqlDataReader
There are 10 kinds of people: those who understand binary and those who don't
-
Yes, you need a loop. I gave you a solution to a problem, though i would rather work with SqlDataReader
There are 10 kinds of people: those who understand binary and those who don't
Ok understood. Thanks to spend your time with me :-D Regards, Hogan