Showing posts with label Entity Framework. Show all posts
Showing posts with label Entity Framework. Show all posts

Monday, July 23, 2012

Entity Framework In ASP.NET

Entity Framework At-a-Glance




The Microsoft ADO.NET Entity Framework is an Object/Relational Mapping (ORM) framework that enables developers to work with relational data as domain-specific objects, eliminating the need for most of the data access plumbing code that developers usually need to write. Using the Entity Framework, developers issue queries using LINQ, then retrieve and manipulate data as strongly typed objects. The Entity Framework’s ORM implementation provides services like change tracking, identity resolution, lazy

Tuesday, June 12, 2012

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

Using Dynamic Data Functionality to Format and Validate Data


In the previous tutorial you implemented stored procedures. This tutorial will show you how Dynamic Data functionality can provide the following benefits:




  • Fields are automatically formatted for display based on their data type.

  • Fields are automatically validated based on their data type.

  • You can add metadata to the data model to customize formatting and validation behavior. When you do this, you can add the formatting and validation rules in just one place, and they're automatically applied everywhere you access the fields using Dynamic Data controls.


To see how this works, you'll change the controls you use to display and edit fields in the existing Students.aspx page, and you'll add formatting and validation metadata to the name and date fields of the Student entity type.

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

Using Stored Procedures


In the previous tutorial you implemented a table-per-hierarchy inheritance pattern. This tutorial will show you how to use stored procedures to gain more control over database access.


The Entity Framework lets you specify that it should use stored procedures for database access. For any entity type, you can specify a stored procedure to use for creating, updating, or deleting entities of that type. Then in the data model you can add references to stored procedures that you can use to perform tasks such as retrieving sets of entities.

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

Implementing Table-per-Hierarchy Inheritance


In the previous tutorial you worked with related data by adding and deleting relationships and by adding a new entity that had a relationship to an existing entity. This tutorial will show you how to implement inheritance in the data model.


In object-oriented programming, you can use inheritance to make it easier to work with related classes. For example, you could create Instructor and Student classes that derive from a Person base class. You can create the same kinds of inheritance structures among entities in the Entity Framework.

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

Working with Related Data, Continued


In the previous tutorial you began to use the EntityDataSource control to work with related data. You displayed multiple levels of hierarchy and edited data in navigation properties. In this tutorial you'll continue to work with related data by adding and deleting relationships and by adding a new entity that has a relationship to an existing entity.


You'll create a page that adds courses that are assigned to departments. The departments already exist, and when you create a new course, at the same time you'll establish a relationship between it and an existing department.


Image02

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.