I am updating a web application and have decided to use SubSonic as it seems awesome and I want to learn it 🙂 I’m trying to return a SQLDataReader from a method I already have and have done it like this
public SqlDataReader GetAllCarTypes_dr()
{
return (SqlDataReader)new Query("tblCarType").ExecuteReader();
}
Just checking this is the correct way to do it? Or is there a better subsonic syntax like ExecuteSQLDataReader()?
The way you have specified is one way you can do it. However, there is no
ExecuteSQLDataReader()function because it is redundant.Since
SQLDataReaderalready implements theIDataReaderinterface, there’s no point in creating a function specific to aSQLDataReader.You may consider returning the interface in the same manner SubSonic does, for example:
and performing the assignment in your logic:
I would consider this the best way to do it.