Filtering strongly typed DataSets
Is there an easier way to filter on stongly typed DataSets?
public PubsDataSet GetFilteredTypedDataSets(PubsDataSet dsp, string filter){
//filter the rows from a copy of the authors table
DataRow[] foundRows = dsp.authors.Copy().Select(filter); //delete the authors from the typed dataset
dsp.authors.Clear(); //merge the filtered rows back to the typed dataset
dsp.Merge(foundRows,false,MissingSchemaAction.Add); return dsp;
}
If you don't want the DataRow merged back to the typed DataSet, you can work with them directly by casting the DataRow to a typed version:
foreach(PubsDataSet.authorsRow r in foundRows)Console.WriteLine(r.au_fname);
DataSets are really nice, and strongly typed DataSets even more so :)