Chapter 14. Binding Entities to Data-Aware Controls

Data-binding the Entity Framework's generic ObjectContext.EntitySet collections and their members to data-aware Widows form and ASP.NET server controls follows Microsoft's original Wizard-based drag-and-drop pattern for typed DataSets. In most cases, you use similar databinding methodology with typed DataSets, LINQ to SQL and Entity Framework (EF) data sources. Windows forms require that you add a node for the top-level (master) EntitySet to the Data Sources window; if the relationships/associations have been specified correctly, the master EntitySet will have nested EntityCollection(s) for one:many associations. It's a common practice to drag the master node to the form to create a details view with a BindingNavigator, BindingSource and multiple bound TextBox controls. Nested EntityCollection nodes commonly generate DataGridView controls to enable selection and editing of associated entities. ASP.NET's EntityDataSource control lets developers bind data-aware, sorted, paged GridView or FormView controls to an EntitySet by specifying a few control properties.

A "demoware" stigma afflicts Windows and, to a lesser degree, Web form projects that rely on autogenerated databound controls. The implication is that "real developers don't use wizards and drag-and-drop techniques" to create industrial-quality applications. However, automating the databinding process can markedly increase programmer productivity, especially for small to moderate-size ...

Get Professional ADO.NET 3.5 with LINQ and the Entity Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.