O'Reilly logo

Programming Entity Framework, 2nd Edition by Julia Lerman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Data Binding with Windows Forms and WPF Applications

So far, you’ve seen how to interact directly with an EDM using snippets of code in a console application. Although there is much more to learn about the Entity Framework, at this point it’s time to see how you can use the Entity Framework as part of your applications.

In this chapter, you will explore basic data-binding scenarios in Windows Forms and Windows Presentation Foundation (WPF). You’ll see how the Entity Framework objects work with Visual Studio’s data-binding features in much the same way that DataTables and DataSets do, without having to explicitly set and retrieve the values of each control. The data binding’s change notification mechanism works automatically with the Entity Framework’s change tracking, so editing data that was queried through the Entity Data Model does not require a lot of extra coding. In the examples here, you’ll bind directly to the results of Entity Framework queries as you learn the concepts. In Chapter 26, after you have learned much more about the Entity Framework, I will address n-tier applications and more robust patterns for enterprise applications.

The chapter will begin with data binding in Windows Forms and will then move on to the WPF techniques.

Data Binding with Windows Forms Applications

To demonstrate data binding of an EDM in a Windows form, let’s build a small application to let you view customers and their reservations as well as edit the customers and add new reservations. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required