Chapter 4. Searching and Analyzing Data
4.0. Introduction
This chapter focuses on searching for records in views and tables, calculating values based on values in those or other tables, and navigating data relations between tables.
The DataView is a data-bindable view of a DataTable that presents data with different sort orders and filters. You can create multiple views for each table; every table has a default data view. The DataViewManager class helps to manage the default data views for tables in a DataSet. Recipe 4.5 shows how to use the DataView to filter and sort data in a DataSet. Recipe 4.6 shows how to filter a data view for rows that have null values.
The DataTable and DataView classes both provide several ways to locate records from specified criteria. Searching an existing table or view saves a roundtrip to the database server. Although the DataView is created from a DataTable, searching is done differently in each. Recipe 4.4 shows how to find rows in a DataTable and in a DataView. Recipe 4.7 shows how to access deleted rows in DataTable.
ADO.NET does not provide a way to compare two DataSet objects with identical schemas to determine the data differences between the two. Recipe 4.1 creates a method GetDataSetDifference() that returns the differences as a DiffGram, which is an XML format that identifies original and current versions of data and is used by .NET to serialize and persist the DataSet.
In addition to recipes about the DataRelation, DataSet, DataTable, and DataView ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access