Data Binding and LINQ to DataSet

Data binding is the process that establishes a connection between the application UI and business logic. If the binding has the correct settings and the data provides the proper notifications, when the data changes its value, the elements that are bound to the data reflect changes automatically. The DataSet is an in- memory representation of data that provides a consistent relational programming model, regardless of the source of the data it contains. The ADO.NET 2.0 DataView enables you to sort and filter the data stored in a DataTable. This functionality is often used in data-binding applications. By using a DataView, you can expose the data in a table with different sort orders, and you can filter the data by row state or based on a filter expression. For more information about the DataView object, see DataViews (ADO.NET).

LINQ to DataSet allows developers to create complex, powerful queries over a DataSet by using Language-Integrated Query (LINQ). However, a LINQ to DataSet query returns an enumeration of DataRow objects, which is not easily used in a binding scenario. To make binding easier, you can create a DataView from a LINQ to DataSet query. This DataView uses the filtering and sorting specified in the query, but is better suited for data binding. LINQ to DataSet extends the functionality of the DataView by providing LINQ expression-based filtering and sorting, which allows for much more complex and powerful filtering and sorting operations than string-based filtering and sorting.

Note that the DataView represents the query itself and is not a view on top of the query. The DataView is bound to a UI control, such as a DataGrid or a DataGridView, providing a simple data binding model. A DataView can also be created from a DataTable, providing a default view of that table.

In This Section

See Also

Other Resources

Programming Guide (LINQ to DataSet)