I'm trying to retrieve records from a table in MS Access 2010 using OleDbDataReader. In some cases the table I am retrieving records from has multiple records for the supplied query. For example: Two tables; Ist table has two columns - one is Name(primary key) the other contains numbers. 2nd table contains many fields; one being the Name field as the foreign key. In some cases my query matches a record that in both tables returns ONE record, but on other cases there is one record from 1st table, but many records from 2nd table. So my datareader only pulls in one of those records that populates the textboxes. So I wanted to find a way to put those multiple records into a listbox and I asked the question on this forum. The answer given was to use LINQ and "put the results in a List/IEnumerable". I wish is was only that simple. I've tried to incorporate List/IEnumerable and and I'm not only going backwards, but becoming more and more confused. My understanding is that I have to create a whole new class, constructor, set of methods, etc and create a list that will take any type(int, string, etc). IS this correct? Does my new class start with
public class myList : IEnumerable<T>
{
public IEnumerable<T> GetEnumerator()
{
foreach (object o in objects)
{
yield return 0;
}
}
}
Inside method in Form class
while (myreader.Read())
{
foreach (object o in myList) //do something
}
The T being any type whereas I would otherwise use int or string?