CHAPTER 1 N THE FOUNDATIONS OF ADO.NET DATA SERVICES
5
developer does not need to write tedious code to achieve this aim. Several object relational
mappers are available to .NET developers, such as NHibernate, but this book will focus on
Microsoft’s own ADO.NET Entity Framework, because of its close relationship with ADO.NET
Data Services and LINQ, using LINQ to Entities.
The Concept of Service Orientation
With set- based logic helping us access data and object orientation helping us implement busi-
ness logic on that data, the final problem that needs to be solved in order to meet the original
requirement is moving this data across a network. The concept of service orientation deals
with this requirement by communicating data in discrete messages between a sender and
a receiver application. The sender is commonly called the client or proxy and the receiver is
the service.
The sent messages must conform to a contract dictated by the service. The contract defines
exactly what structure of data is accepted by the service and how the data can be used. The
format (such as XML) and encoding (such as text) of the message may differ, and the low- level
protocol (transport) used for communication may differ also; however, by considering com-
munication of data as encoded messages being sent and received over a transport using a set
contract, service orientation loosely couples the sender and receiver, and acknowledges that
the technology implementation of the transport and encoding may change over time. Indeed, we
may also want to use different transports and encodings for different clients. For example, we may
want to expose a service to external customers over the Internet using the Hypertext Transfer
Protocol (HTTP) transport with a text encoding, but internally we may want to communicate
using TCP/IP and a binary encoding, because internally we have control of the development of
our own clients and the security of our network.
In .NET, the concept of service orientation is delivered using Windows Communication
Foundation (WCF), and ADO.NET Data Services is built on top of this foundation. WCF is
described in detail later on in this chapter in the section “The ABCs of Windows Communica-
tion Foundation.”
RESTful Thinking
If you have designed components or services in the past, you are most likely to have devel-
oped an interface or service contract, where you define what operations a component is
allowed to perform. For example, you might design a contract that contains three opera-
tions: CapLnk`q_p>uE`( LanoeopLnk`q_p, and @ahapaLnk`q_p. Each of these operations deals
with a product entity and defines what you can do with a product. In other words, each
operation is a verb, and it deals with the product entity, which is a noun.
Why do we write service contracts containing operations describing what a client can
do with the service? It is because there is commonly no other mechanism for understanding
how a service can be consumed. But the majority of web services use HTTP as their transport.
This protocol specifies HTTP verbs that must be sent in the request message. Therefore, if we
are only exposing our service over HTTP, it is possible to use the protocol itself to understand
the intent. This is the architecture proposed by Roy Fielding when he first described a style of
service- oriented architecture (SOA) known as representational state transfer (REST).