Wednesday, June 13, 2012

Using JSON with ASP.NET 3.5

Introduction


Almost any application that you write will involve exchanging data from a client application to the server. This process involves selecting a data format and exchange protocol that will be required to enable this communication. When it comes to selecting these data formats, you have a variety of open standards that you can consider and the ideal choice depends on the requirements of the application.


For example, if you use SOAP based Web services, you format the data in an XML payload that is wrapped within a SOAP envelope. Although XML works well for many application scenarios, its inherent chatty nature makes it less than ideal for certain scenarios. For example, in an AJAX style Web application, you make asynchronous lightweight out-of-band calls to the server side to get the required data without even refreshing the browser. In this scenario, you need a lightweight, open, text-based platform independent data exchange format for transferring data back and forth between the client and server. That’s exactly what the JSON (Java Script Object Notation) standard provides.

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