Tuesday, June 12, 2012

The Entity Framework and ASP.NET – Getting Started Part 4

Working with Related Data


In the previous tutorial you used the EntityDataSource control to filter, sort, and group data. In this tutorial you'll display and update related data.


You'll create the Instructors page that shows a list of instructors. When you select an instructor, you see a list of courses taught by that instructor. When you select a course, you see details for the course and a list of students enrolled in the course. You can edit the instructor name, hire date, and office assignment. The office assignment is a separate entity set that you access through a navigation property.


You can link master data to detail data in markup or in code. In this part of the tutorial, you'll use both methods.

The Entity Framework and ASP.NET – Getting Started Part 3

Filtering, Ordering, and Grouping Data


In the previous tutorial you used the EntityDataSource control to display and edit data. In this tutorial you'll filter, order, and group data. When you do this by setting properties of the EntityDataSource control, the syntax is different from other data source controls. As you'll see, however, you can use the QueryExtender control to minimize these differences.


You'll change the Students.aspx page to filter for students, sort by name, and search on name. You'll also change the Courses.aspx page to display courses for the selected department and search for courses by name. Finally, you'll add student statistics to the About.aspx page.

The Entity Framework and ASP.NET – Getting Started Part 2

The EntityDataSource Control


In the previous tutorial you created a web site, a database, and a data model. In this tutorial you work with the EntityDataSource control that ASP.NET provides in order to make it easy to work with an Entity Framework data model. You'll create a GridView control for displaying and editing student data, a DetailsView control for adding new students, and a DropDownList control for selecting a department (which you'll use later for displaying associated courses).


Image20


Image09


Image18

The Entity Framework and ASP.NET – Getting Started Part 1


Introduction





The Contoso University sample web application demonstrates how to create ASP.NET Web Forms applications using the Entity Framework. The sample application is a website for a fictional Contoso University. It includes functionality such as student admission, course creation, and instructor assignments.

This tutorial series uses the ASP.NET Web Forms model and assumes you know how to work with ASP.NET Web Forms in Visual Studio. If you prefer to work with the ASP.NET MVC framework, see the Creating Model Classes with the Entity Framework tutorial or the Getting Started with the Entity Framework using ASP.NET MVC tutorial series.


Overview


The application you’ll be building in these tutorials is a simple university website.


Image03


Users can view and update student, course, and instructor information. A few of the screens you'll create are shown below.

2 Tier Vs 3 Tier Architecture

Abstract


This article i will describe you to migrate your application from 2-Tier architecture to the most advance Data Access methodology available in .Net 4.0.Please keep watching all migration articles one by one. If it really helps you out then please don't forget to put your feedback and comments.


2 Tier Architecture

If you are writing all the data access logic inside your code behind, I guess your code looks like this.




  • While Inserting Data into Database:
    SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["EmployeeConString"].ConnectionString);


SqlCommand sqlCommand = new SqlCommand(string.Format("INSERT INTO Department (DepartmentId, Name, Budget, StartDate) VALUES ({0}, '{1}', {2}, '{3}')", txtDeptId.Text, txtDeptName.Text, txtBudget.Text, txtStartDate.Text), sqlConnection);