tags:

views:

474

answers:

2

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()??

A: 

Ahhaaa.. should have thought about it before O posted, think I have it now

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

If not please can you post up the correct syntax

leen3o
+1  A: 

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

public DataTable GetAllCarTypes()
{
    return new Query("tblCarType").ExecuteDataSet().Tables[0];
}
John Rasch
Ugly but correct. SubSonic definitely needs ExecuteDataTable(). Why anyone uses a DataSet when they only need a DataTable is beyond me.
Matt