Home All Groups Group Topic Archive Search About

CreateChildView() vs DataTable.Select() on entire table

Author
25 Aug 2006 6:06 PM
bfking
Can anyone shed some light on why DataRowView.CreateChildView() would
significantly slower than DataTable.Select()?

my DataSet looks like this
DataSet ds;    //ds assignment code left out for simplicity
ds.Tables["IDs"].PrimaryKey = new DataColumn[]{
ds.Tables["IDs"].Columns["ID"] };
ds.Tables[0].PrimaryKey = new DataColumn[]{ ds.Tables[0].Columns["ID"],
ds.Tables[0].Columns["STID"] };

ds.Relations.Add("myRelation", ds.Tables["IDs"].PrimaryKey, new
DataColumn[] {ds.Table[0].Columns["ID"]});

ds.Tables["IDs"] was created from Unique ID's in ds.Tables[0]..

then when looping ds.Tables["IDs"].DefaultView...

DataView dv = myDataRowView.CreateChildView("myRelation");

is slower than...

DataRow[] drs =
myDataRowView.DataView.Table.DataSet.Table[0].Select(string.format("ID
= '{0}'"), myDataRowView["ID"});

with 3000 rows in Table[0], i have a piece of code that takes 10-11
secs to run using CreateChildView() vs .05 secs using Select().

i would just use the Select() method, but i lose the ability to use
BoundFields in a GridView (and also Eval in the TemplateFields.  i have
to cast the DataItem each time i want to access a field in the DataRow)

any advise would be greatly appreciated.

thanks,
bk

Author
25 Aug 2006 6:29 PM
bfking
forgot to mention i'm using Framework 2.0

bfking wrote:
Show quote
> Can anyone shed some light on why DataRowView.CreateChildView() would
> significantly slower than DataTable.Select()?
>
> my DataSet looks like this
> DataSet ds;    //ds assignment code left out for simplicity
> ds.Tables["IDs"].PrimaryKey = new DataColumn[]{
> ds.Tables["IDs"].Columns["ID"] };
> ds.Tables[0].PrimaryKey = new DataColumn[]{ ds.Tables[0].Columns["ID"],
> ds.Tables[0].Columns["STID"] };
>
> ds.Relations.Add("myRelation", ds.Tables["IDs"].PrimaryKey, new
> DataColumn[] {ds.Table[0].Columns["ID"]});
>
> ds.Tables["IDs"] was created from Unique ID's in ds.Tables[0]..
>
> then when looping ds.Tables["IDs"].DefaultView...
>
> DataView dv = myDataRowView.CreateChildView("myRelation");
>
> is slower than...
>
> DataRow[] drs =
> myDataRowView.DataView.Table.DataSet.Table[0].Select(string.format("ID
> = '{0}'"), myDataRowView["ID"});
>
> with 3000 rows in Table[0], i have a piece of code that takes 10-11
> secs to run using CreateChildView() vs .05 secs using Select().
>
> i would just use the Select() method, but i lose the ability to use
> BoundFields in a GridView (and also Eval in the TemplateFields.  i have
> to cast the DataItem each time i want to access a field in the DataRow)
>
> any advise would be greatly appreciated.
>
> thanks,
> bk

AddThis Social Bookmark Button