Lesson 14:
LINQ and the ADO.NET Entity Framework

Introduction

This week in Chapter 14: LINQ and the ADO.NET Entity Framework you will learn how to write Language Integrated Quieries (LINQ) which are very similar to standard SQL queries the main difference is you can use them in your C# code-behind files.

You will also be introduced to the ASP.NET Entity framework which gives Visual Studio some very powerful classes for creating C# data models from SQL tables or if you prefer SQL tables from C# models - this is the basis for Microsoft's latest Web development paradigm MVC (Model-View-Controller). To be a professional Web developer in the modern era you will definitely want to be very skilled at using the .NET Entity framework and how to use it to bind data.

You will also be learning about the ListView control which is based on C# collections and is a very neat control for binding data to including RSS feeds (that's right you can easily pull any site's blog posts into your Web pages) and other other XML data sources, in addition to SQL tables and views, and even object collections.

Assignment

This week you will get an opportunity to use some very powerful features of ASP.NET. You will use the Entity Frawme to create C# models from your Review and Genre tables on the Student SQL server. You will allows be using language integrated queries (LINQ) to query and filter your data sources. In order to be ready for next week's assignment submission you will need to have the following tasks completed by the end of Week 14:

  • Read all of Chapter 14: LINQ and the ADO.Net Entity Framework in your ASP.NET text book
  • Complete all 10 of the steps below to update your All.aspx and AllByGenre.aspx pages in your Reviews folder and to add a new Photo Album feature to your Web site.
  •  Publish all new and updated files in your Web site to the CIS Student Web server.
  • Post Your PhotoAlbum URL for Scoring

Instructions

Use the following step-by-step instructions for completing this week's assignment. Remember to use C# when copying code snippets from your text book and adding new items to your site which use code-behind files.

Installing the Entity framework using the NuGet Package Manager.
The Installed tab of the NuGet Package Manager showing the installed packages for the Website.

Note: You will need to have the ADO.NET Entity Framework installed in order to complete this weeks Try It Outs. If you have not already added the Entity Framework to your Website, open the Tools menu and navigate to and rest your mouse over Nuget Package Manager and choose Manage NuGet Packages for Solution. If the Entity Framework does not appear in the list of installable choices then search for Entity Framework. When you select the Entity Framework in the left column you will see a box in the right column that lists your Website name and a checkbox next to it. Put a check in the box next to your Website name (CSIS786 in image) and then click the Install button to install the framework's assembly files in your website.

Step 1: Complete all the steps in the first Try It Out in Chapter 14 A Simple LINQ to Entities Example on pages 489 - 491 to add PlanetWrox ADO.NET Entity Data Model to your App_Code folder and update the All.aspx page and its code-behind file in your Reviews folder with a GridView control which uses the PlanetWroxEntities as its data source.

Step 2: Complete all the steps in the second Try It Out in Chapter 14 Working with Queries and Anonymous Types on pages 501 - 502 to update your AllByGenre.aspx page and its code-behind file in your Reviews folder to include a Repeater control which contains a <h3> element wrapped around an ASP.NET Literal control which bound to the Name field of your Reviews table and a ASP.NET BulletedList control with the properties shown in the table on page 502.

Step 3: Complete all the steps in the third Try It Out in Chapter 14 A Simple Model Binding Application on pages 505 - 509 to add two new tables PhotoAlbum and Picture to your SQL database and update your Entity Framework model to reflect the addition of the two new tables, and add a new Web Form to the root of your site calling it NewPhotoAlbum.aspx with a title of Create New Photo Album and a DetailsView control with an InsertMethod as shown in figure 14-10 of your textbook - be sure to add the necessary code to the code-behind file as well.

 Step 4: Complete all the steps in the fourth Try It Out in Chapter 14 Inserting and Deleting Data with the ListView Control on pages 513 - 518 to add a new Web Form to the root of your site based on your custom template called ManagePhotoAlbum.aspx and set its title to Manage Photo Album which includes a ListView control as shown in Step 3 of the Try It Out and add the stated code to the page's code-behind file.

Step 5: Complete all the steps in the fifth Try It Out in Chapter 14 Using Strongly Typed Data-Bound Controls on pages 523 - 524 to modify the ListView control in your ManagePhotoAlbum.aspx page.

Step 6: Complete all the steps in the sixth Try It Out in Chapter 14 Customizing Templates of the ListView Control on pages 525 - 527 to add a new folder named GigPics off the root of your Website and modify the ManagePhotoAlbum.aspx page as stated.

Step 7: Complete all the steps in the seventh Try It Out in Chapter 14 Paging Data with the ListView and DataPager Controls on pages 530 - 534 to create the front-end page for the GigPics feature.

Step 8 Publish the following files and folders to the Student Web server:

  • NewPhotoAlbum.aspx file off the root of your Web site.
  • ManagePhotoAlbum.aspx file off the root of your Website.
  • App_Code folder off the root of your Web site.
  • Bin folder off the root of your Web site.
  • GigPics folder off the root of your Web site.
  • Reviews folder of the root of your Web site.
  • Web.config file off the root of your Web site.

Step 9 Validate that the updates and additions to your Website are working on the Student Web server.

Step 10 Post the URL for your NewPhotoAlbum.aspx file to Canvas for scoring by the due date listed in the Syllabus. Example: http://IA.MSJC.EDU/7-digit student ID number/NewPhotoAlbum.aspx

Instructor's Note: Everything MUST be completed before the due date listed in the syllabus for this assignment.

Please email me if you have any questions at all!

⇑Table of Contents

Lesson Summary

In this lesson you learned how to:

  • Use LINQ to create datasets
  • Recognize the different forms of LINQ
  • Use the ADO.NET Entity framework
  • Use the ListView and DataPage controls

Congratulations, that's it for this assignment. You can get a head start on your next lesson by reading chapter 15 in your textbook.

⇑Table of Contents