<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ThumNet &#187; adonet</title>
	<atom:link href="http://blog.thumnet.com/tag/adonet/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.thumnet.com</link>
	<description>Just a ThumNet blog</description>
	<lastBuildDate>Fri, 06 Aug 2010 09:34:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>ADO.NET Dataservices</title>
		<link>http://blog.thumnet.com/adonet-dataservices/81/</link>
		<comments>http://blog.thumnet.com/adonet-dataservices/81/#comments</comments>
		<pubDate>Fri, 29 May 2009 16:30:12 +0000</pubDate>
		<dc:creator>Laurens 't Hardt</dc:creator>
				<category><![CDATA[DevDays09]]></category>
		<category><![CDATA[adonet]]></category>
		<category><![CDATA[qnh]]></category>

		<guid isPermaLink="false">http://blog.thumnet.com/?p=81</guid>
		<description><![CDATA[ADO.NET Dataservices is a new way to open your data to the web. It&#8217;s especially usefull in combination with a Rich Internet Client Application, such as a silverlight application or an AJAX application. Dataservices is an implementation of WCF but has some restrictions to it. Dataservices makes use of the ATOM or the JSON format [...]]]></description>
			<content:encoded><![CDATA[<p>ADO.NET Dataservices is a new way to open your data to the web. It&#8217;s especially usefull in combination with a Rich Internet Client Application, such as a silverlight application or an AJAX application.</p>
<p>Dataservices is an implementation of WCF but has some restrictions to it.</p>
<ul>
<li>Dataservices makes use of the ATOM or the JSON format to transport the data, no other format is supported.</li>
<li>The data is transported over the HTTP or HTTPS protocol and no other protocol is supported.</li>
<li>Agarding to authentication you can´t use of the WCF authentication model. You are restricted to the standard authentication model ASP.NET offers you, Windows Authentication and Forms authentication.</li>
<li>Dataservices has a REST based interface implementation, witch means a request to the service can only be done using REST.</li>
</ul>
<p><strong>Getting started with Dataservices.</strong></p>
<p>To get started with Dataservices you first need to define a datasource. This datasource needs to implement IQueryable&lt;T&gt; for the Dataservices to use it. Two commonly used framework that implement this interface are LINQ2SQL and the Entity Framework. For use with Dataservices it&#8217;s prefered to use the EntityFramework. The  IQueryable&lt;T&gt;makes it possible for Dataservices to query the data but to be able to update insert and delete data the datasource also has to implement the IUpdateAble&lt;T&gt; interface, wich is implemented by the Entity Framework and not by LINQ2SQL.</p>
<p>Now the datasource is created the Dataservice has to be created. There is a new template for adding the dataservice in Visual Studio 2008 SP1.</p>
<div id="attachment_83" class="wp-caption alignnone" style="width: 176px"><img class="size-full wp-image-83" src="http://blog.thumnet.com/wp-content/uploads/2009/05/adodsserviceitem.png" alt="New Ado Service" width="166" height="71" /><p class="wp-caption-text">New Ado Service</p></div>
<p>After this has been added the dataservice needs to be pointed to the datasource, below is a sample of that where a NorthwindDataService  is Created which is pointed to a NorthwindDataContext. In the example the security is also set to read for all entities in the InitializeService method. The security can be set per entity and per method.</p>
<pre class="brush: csharp;">
public class NorthwindDataService : WebDataService&lt;NorthwindDataContext&gt; {
InitializeService(IWebDataServiceConfiguration config)
{
config.SetResourceContainerAccessRule
(&quot;*&quot;, ResourceContainerRights.AllRead);
}
}
</pre>
<p>Dataservices is queried by REST, this can be tested in a browser by calling the service. In the examples below it&#8217;s shown how to query the service. For this example the url of the service is <em>&#8216;http://localhost:5555/Bookmarks.svc&#8217;.</em></p>
<p>The url below request for the model of the data.</p>
<p><em>&#8216;http://localhost:5555/Bookmarks.svc$metadata&#8217;</em></p>
<div id="attachment_85" class="wp-caption alignnone" style="width: 582px"><img class="size-full wp-image-85" src="http://blog.thumnet.com/wp-content/uploads/2009/05/dataservicesmetadata.jpg" alt="Metadata" width="572" height="416" /><p class="wp-caption-text">Metadata</p></div>
<p>To request a list of all the bookmarks put the url below in the browser. Here the <em>&#8216;/Bookmarks</em><em>&#8216; </em>refers to the entityset Bookmarks.</p>
<p><em>&#8216;http://localhost:5555/Bookmarks.svc/Bookmarks&#8217;</em></p>
<p>As is shown in the metadata the key of Bookmark is the Id property. Every entity needs a key property. To get just 1 bookmark with id 1 the following url can be used:<br />
<em>&#8216;http://localhost:5555/Bookmarks.svc/Bookmarks(1)&#8217;</em></p>
<p>It&#8217;s also possible to get a list of entities based upon a filter. For example get all bookmarks with Tags Devdays. This is done by using keywords, which always begin with a ´$´, in the querystring.</p>
<p><em>&#8216;http://localhost:5555/Bookmarks.svc/Bookmarks?$filter=Tags eq Devdays&#8217;</em></p>
<p><em><span style="font-style: normal;">For Silverlight applications it&#8217;s possible to query dataservices using LINQ2Dataservices so you don&#8217;t have to create these url&#8217;s yourself buth you can just use LINQ to create queries.</span></em></p>
<p><em><span style="font-style: normal;">Much more information about ADO.NET Dataservices can be found on <a title="MSDN" href="http://msdn.microsoft.com/en-us/data/bb931106.aspx">MSDN</a>.</span></em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thumnet.com/adonet-dataservices/81/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
