ODS cast to dataset

How do I cast an objectdatasource.select() to a dataset?
acdagirlAsked:
Who is Participating?
 
ozymandiasConnect With a Mentor Commented:
You are correct...the ods.select method *COULD* return a datatable, but it could also return any object that implements IEnumerable.

If you want to try it, do this :

object obj = objectdatasource.select();
if (obj is DataTable){
    // we have a data table
    DataSet data = new DataSet();
    DataTable table = (DataTable)obj;
    data.Tables.Add(table);
    // now you have a dataset with your datatable int it
   // do your stuff
}else{
    /// ooops
    System.Diagnostics.Debug.WriteLine("Object retirned by objectdatasource was not a datatable is was a " + obj.GetType.ToString());
}
0
 
ozymandiasCommented:
I don't thinb you can cast it to a dataset since the return type is IEnumerable and DataSet does not implement this interface AFAIK.
0
 
acdagirlAuthor Commented:
i thought the ods.select method could return a datatable, from which you could get a dataset?
either way, I'm just trying to pass the object datasource dataset/view/table in a session to another page instead of reloading it. I guess I can just call the datatable I have in the business logic layer that calls the datatable and avoid the object datasource altogether...
0
All Courses

From novice to tech pro — start learning today.