2011-11-15 2 views
0

Dans Subsonic 2.1, comment obtenir le type T à partir de Find?Dans Subsonic 2.1, comment trouver un objet fortement typé?

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

Je souhaite que le résultat soit de type Animal non IDataReader. Comment puis-je convertir IDataReader en Animal? J'espère qu'il existe une méthode SubSonic ou Framework pour faire cela pour moi.

Répondre

1

Essayez cette (du 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 
} 
+0

Merci pour la grande réponse. Je travaille maintenant sur l'obtenir dans une bonne méthode d'extension: http://stackoverflow.com/questions/8154395/ –

Questions connexes