Search code examples
subsonic

How Do I return a DataTable from a SubSonic Query?


I'm trying to return a datatable from a query I have written in Subsonic (I'm just starting to learn it) - But can only return a DataSet?

public DataTable GetAllCarTypes()
{
    return new Query("tblCarType").ExecuteDataSet();
}

I was hoping for .ExecuteDataTable()??


Solution

  • If you're only returning 1 table from the query, you can do:

    public DataTable GetAllCarTypes()
    {
        return new Query("tblCarType").ExecuteDataSet().Tables[0];
    }