Using the Data Model

The basic approach to using the entity data model is to create an instance of the entity context class and then use its properties to access the contents of the tables. In the tables, each row is represented by entity objects, which are instantiations of the entity classes that you saw modeled in Figure 8-9. We can use these objects and properties to query and manipulate the data in the database, as the following sections demonstrate.

Querying the Data Model

Listing 8-1 shows the contents of a web page to add to our project using the name ListEvents.aspx.

Listing 8-1. A simple web page

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ListEvents.aspx.cs"  Inherits="DataApp.ListEvents" %> <!DOCTYPE html PUBLIC "-//W3C//DTD ...

Get Applied ASP.NET 4 in Context 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.