0

In Subsonic 2.1 how do I get type T from Find?

        Animal criteria = new Animal();
        IDataReader result = Animal.Find(criteria);

I want result to be of type Animal not IDataReader. How can I convert IDataReader to Animal? I hope there is a SubSonic or Framework method to do this for me.

David Silva Smith
  • 11,498
  • 11
  • 67
  • 91

1 Answers1

1

Try this (from the Getting Started PDF Documentation):

IDataReader result = Animal.Find(criteria);
AnimalCollection coll = new AnimalCollection();
coll.Load(result);
result.Close();

// do something with coll
foreach (Animal anm in coll)
{
    // do something with animal object
}
mellamokb
  • 56,094
  • 12
  • 110
  • 136