Leverage Cloud Computing with Windows Azure and Windows Phone 7 – Step 3 to Infinity – Under Construction
[アーティクル]
Continuing to build the infrastructure to support our Silverlight based Windows Phone 7 Application
This post is more than just Silverlight or Phone DevThis post is about setting up an entire infrastructure for building service oriented applications. It will include a lot of pieces, including a web site, a web server, an ADO.NET Entity Framework 4 framework, Silverlight, etc.
Building the Infrastructure
Our code will be composed of many projectsIn order for a phone application to talk to the cloud to get data, it needs a few things setup. Here are the things that we are going to build:
A web service that hosts a SL-enabled WCF Service
A Silverlight client for both a browser and a Windows Phone 7
The post is about data
A data tier to host our data
A SQL Azure database and a SQL Server On-Premise database
What is the Entity Framework?
Here is what you should know about the ADO.NET Entity Framework
ADO.NET Entity Framework abstracts the relational (logical) schema of the data that is stored in a database
The developer is presented with a very convenient conceptual schema to write code with
For example, in the database, entries about a customer and their information can be stored in the Customers table, their orders in the Orders table and their contact information in yet another Contacts table. This is a big hassle for the developer to know all this when writing C# code
For an application to deal with this database, it has to know which information is in which table, i.e., the relational schema of the data is hard-coded into the application
The disadvantage of this approach is that if this schema is changed the application is not shielded from the change
The Entity Framework let's you take advantage of intellisense and compile time checking of types against the actual database
It is a lot easier for the developer to perform SQL joins to traverse the relationships of the data elements in order to find related data, because of the help of all the Entity Framework tooling
For example, to find the orders of a certain customer, the customer needs to be selected from the Customers table, the Customers table needs to be joined with the Orders table, and the joined tables need to be queried for the orders that are linked to the customer.
This model of traversing relationships between items is very different from the model used in object-oriented programming languages, where the relationships of an object's features are exposed as Properties of the object and accessing the property traverses the relationship
The point is simplify the traversing of relationships
Also, using SQL queries expressed as strings, only to have it processed by the database, keeps the programming language from making any guarantees about the operation and from providing compile time type information
Magic strings, even if they are SQL queries, are evil. The database could change and your code is none-the-wiser and you will end up with runtime errors instead of compile time errors
The mapping of logical schema into the physical schema that defines how the data is structured and stored on the disk is the job of the database system and client side data access mechanisms are shielded from it as the database exposes the data in the way specified by its logical schema
Peter Chen Interview – the inventor of object relational mapping
Step 0: Prerequisite. Make sure you have created this database: https://blogs.msdn.com/b/brunoterkaly/archive/2010/07/22/how-to-quickly-create-a-useful-developer-database-for-sql-server-2008-r2.aspx
Step 1: Add a 'class library' project to the solution. This class library will expose our ADO.NET Entity Framework data.
Step 2: Add an ADO.NET Entity Framework item to our 'class library' project
Step 3: Continue to next blog post where we talk about exposing this data layer from our SL-enabled WCF Service.
To be continued…
Comments
Anonymous
August 09, 2010
Is this series going to be finished?