Data Operations with EF Entities

To get you started querying against EF entities, we’ll dive right into some C#-based examples.

Querying Entity Data Using LINQ to Entities

Returning to your WPF example project, open the source file MainWindow.xaml in the XAML designer. Using the Toolbox window, click and drag a Button and drop it onto the window next the existing button. Name this button btnEntitySelect1, then double-click it to generate its Click event handler code in MainWindow.xaml.cs, and then add the code in Listing 47.7 to btnEntitySelect1_Click.

LISTING 47.7 Using LINQ to Entities to Bind Data to a WPF DataGrid

private void btnEntitySelect1_Click(object sender,RoutedEventArgs e){  AdventureWorks2012Entities ...

Get Microsoft® SQL Server 2012 Unleashed 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.