Posts Tagged ‘Astoria’

“The goal of Microsoft Codename Astoria is to enable applications to expose data as a data service that can be consumed by web clients within corporate networks and across the internet. The data service is reachable over regular HTTP requests, and standard HTTP verbs such as GET, POST, PUT and DELETE are used to perform operations against the service”

In it’s simplest form, it really seems like a web data access layer to your database.  This also looks like it might be Microsoft’s offering for REST-style web service developers. Semantic web here we come!

There’s quite a few components you’ll need installed before you can start playing with it

  1. VS 2008 Beta 2
  2. SQL Server 2005 or Express
  3. Astoria Sept 2007 CTP
  4. ADO.NET Entity Framework Beta 2 (Runtime)
  5. ADO.NET Entity Framework (Tools)

Once you’ve downloaded all the required components, setup to get the data services up and running is a piece of cake.  You generate an Entity Data Model from your relational database, add a new “Web Data Service” to your ASP.NET application, and update a generic class to use your new entity model.  For step-by-step instructions, check out the Using Microsoft Codename Astoria document that comes with the installation.  In a matter of moments, you have your entire database wide-open and exposed over http.  Hmmm… this is a little scary – more on this to come…

You can then access your tables through a Uri pointer to specific tables.  You use expressions that query the database as the Uri.

The expressions are fairly intuitive.  Here are some examples:
<service>/Customers[1234] – returns the customer with the id 1234.
<service>/Customres[1234]/Orders – returns the sales orders for the customer with id 1234
<service>/Customers[ALFKI]/Orders[OrderDate gt '1998-1-1']  – returns all posted after 1/1/1998 for customer 1234

For a working example, check out the hosted Northwind data service here:
http://astoria.sandbox.live.com/northwind/northwind.rse/Categories/Products[1]

There’s a lot more complex expressions which include paging, sorting, and the ability to expand elements in an entity that I’ll cover in future posts.

The operators map 1 to 1 with the binary operators in SQL:

Operator Description Example
eq Equal /Customers[City eq ‘London’]
ne Not equal /Customers[City ne 'London']
gt Greater than /Orders[OrderDate gt '1998-5-1']
gteq Greater than or equal /Orders[Freight gteq 800]
lt Less than /Orders[Freight lt 1]
lteq Less than or equal /Orders[OrderDate lteq '1999-5-4']

I would love to hear from some of the REST developers and get your feedback on Microsoft’s direction with these data services.  More to come on this exciting new technology soon, including more abstract concepts on what REST is, and what it means to your current development practices.  Needless to say, I have my apprehensions about it already.  It almost seems like a step backwards where business logic gets closer to the database and n-tier becomes 2-tier.  What do you think?