Is there a way to filter and sort a strongly typed DataTable and end up with a strongly typed result? I know how to use a DataView and to "sort and filter directly in a DataTable," but none of that maintains the strong typing as far as I understand.
Thanks,
Steve
P.S. I've discovered a way to do this as noted in the code below. It's awfully brute force. Does anyone have a more elegant and efficient way to do it?
StronglyTypedDataTableRow[] dr = (StronglyTypedDataTableRow[])
stronglyTypedDataTable.Select(filterString, sortString, DataViewRowState.OriginalRows);
StronglyTypedDataTable dtFilteredAndSorted =
(StronglyTypedDataTable) stronglyTypedDataTable.Clone();
if (dr.Length != 0)
foreach (StronglyTypedDataTableRow drEach in dr)
dtFilteredAndSorted.ImportRow(drEach);