Export (0) Print
Expand All

Course Manager Application

.NET Framework 4

The CourseManager sample demonstrates how to bind Windows Forms controls to data returned by the Entity Framework. This application displays and modifies Course entities associated with Department entities.

This sample is available on the Entity Framework Documentation Samples site on MSDN Code Gallery. The CourseManager Windows forms application created by completing the QickStart.

Scenario

You can bind Windows Forms controls, such as a ComboBox or DataGridView, to the results returned by an instance of the ObjectQuery generic class or EntityCollection generic class. To prevent the query from being executed multiple times during binding, we recommend that you not bind controls directly to ObjectQuery results. Instead, bind controls to the result of the ObjectQuery's Execute method. For more information, see Binding Objects to Controls.

The CourseManager sample creates LINQ to Entities query. It then casts the query to ObjectQuery and calls the Execute method. The result returned from the Exectue method is bound to controls.

Languages

  • C#

  • Visual Basic

  • LINQ to Entities

Prerequisites

Before running this sample, make sure the following software is installed:

  • Visual Studio 2010 containing the .NET Framework 4

  • SQL Server 2005 or 2008 Database Engine

    • School sample database (included in the sample)

    • SQL Server Management Studio (optional)

Building the Sample

Use the following procedure to build the sample.

To build the CourseManager sample application

  1. (Optional) If the School sample database is not already present in your SQL Server instance, run the CreateSchool.sql script included with the project.

  2. Open the solution file in Visual Studio.

  3. (Optional) If you created the School database in an instance of SQL Server other than the default instance on the local machine, specify the correct SQL Server instance by modifying the Data Source in the connection string in the App.Config file of the project.

  4. Build the project.

Removing the Sample

Use the following procedure to remove the CourseManager sample.

To remove the CourseManager Data Binding application

  1. Delete the project directory and contents.

  2. (Optional) Drop the CourseManager database from the instance of SQL Server.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft