سؤال

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.

هل كانت مفيدة؟

المحلول

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
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top