M
mabster
I am trying to retrieve the child rows of a given DataRow using a
relationship, but sort them in the process. There are three ways I can
think of to do this:
1. Use the child table's Select() method to select rows for which the
parent column matches my row's ID, and pass in a sort expression
2. Create a DataRowView from the row (can I do that?), and use the
CreateChildView method
3. Simply use the row's GetChildRows() method and call Array.Sort with a
custom Comparison method
Has anyone done any performance comparisons on these three methods of
returning sorted child rows? Which one am I better off using? I'm
currently enjoying success with the third option, using comparisons like
this:
int CompareRows(DataRow x, DataRow y)
{
return
x["MyStringColumn"].ToString().Compare(y["MyStringColumn"].ToString());
}
Your thoughts?
Cheers,
Matt
relationship, but sort them in the process. There are three ways I can
think of to do this:
1. Use the child table's Select() method to select rows for which the
parent column matches my row's ID, and pass in a sort expression
2. Create a DataRowView from the row (can I do that?), and use the
CreateChildView method
3. Simply use the row's GetChildRows() method and call Array.Sort with a
custom Comparison method
Has anyone done any performance comparisons on these three methods of
returning sorted child rows? Which one am I better off using? I'm
currently enjoying success with the third option, using comparisons like
this:
int CompareRows(DataRow x, DataRow y)
{
return
x["MyStringColumn"].ToString().Compare(y["MyStringColumn"].ToString());
}
Your thoughts?
Cheers,
Matt