<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Matthieu MEZIL : ADO.NET Data Services Hooking POC</title><link>http://msmvps.com/blogs/matthieu/archive/tags/ADO.NET+Data+Services+Hooking+POC/default.aspx</link><description>Tags: ADO.NET Data Services Hooking POC</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>ADO.NET Data Services Hooking POC V4</title><link>http://msmvps.com/blogs/matthieu/archive/2008/10/27/ado-net-data-services-hooking-poc-v4.aspx</link><pubDate>Mon, 27 Oct 2008 23:38:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1652176</guid><dc:creator>Matthieu MEZIL</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/matthieu/rsscomments.aspx?PostID=1652176</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/matthieu/commentapi.aspx?PostID=1652176</wfw:comment><comments>http://msmvps.com/blogs/matthieu/archive/2008/10/27/ado-net-data-services-hooking-poc-v4.aspx#comments</comments><description>&lt;p&gt;I don&amp;#39;t like rights management with ADO.NET Data Services. &lt;/p&gt;
&lt;p&gt;Indeed, you can use a method with ChangeInterceptor attribute to manage CUD operations and a QueryInterceptor attribute&amp;nbsp;to manage Read operations. But if it&amp;#39;s a right logic, I think it should be in the entity class (in the BLL)&amp;nbsp;and not in the service.&lt;/p&gt;
&lt;p&gt;With &lt;a target="_blank" href="http://www.codeplex.com/AstoriaHookingPOC/SourceControl/ListDownloadableCommits.aspx"&gt;my POC&lt;/a&gt;, you just need the entity type implements&amp;nbsp;one or two&amp;nbsp;interfaces:&lt;/p&gt;
&lt;div style="font-size:10pt;background:white;color:black;font-family:Courier New;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;interface&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;IEntityNeedRightToRead&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; CanRead(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; login);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;div style="font-size:10pt;background:white;color:black;font-family:Courier New;"&gt;
&lt;p style="margin:0px;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;interface&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;IEntityNeedRightsToWrite&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0px;"&gt;{&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; CanChange(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; login, &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; propertyName);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; CanChangeLinks(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; login, &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; propertyName);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; CanAdd(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; login);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; CanDelete(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; login);&lt;/p&gt;
&lt;p style="margin:0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Moreover, in my sample, I have the Login property in my entity types so it&amp;#39;s easy to return the default value of a property if you don&amp;#39;t want to expose it for the connected people.&lt;/p&gt;
&lt;p&gt;The next step is, in this case,&amp;nbsp;to exclude the property if it is in ETags.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1652176" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/matthieu/archive/tags/.Net/default.aspx">.Net</category><category domain="http://msmvps.com/blogs/matthieu/archive/tags/ADO.NET+Data+Services/default.aspx">ADO.NET Data Services</category><category domain="http://msmvps.com/blogs/matthieu/archive/tags/ADO.NET+Data+Services+Hooking+POC/default.aspx">ADO.NET Data Services Hooking POC</category></item><item><title>ADO.NET Data Services Hooking POC V3 .1 </title><link>http://msmvps.com/blogs/matthieu/archive/2008/10/19/ado-net-data-services-hooking-poc-v3-1.aspx</link><pubDate>Sun, 19 Oct 2008 06:07:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1651289</guid><dc:creator>Matthieu MEZIL</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/matthieu/rsscomments.aspx?PostID=1651289</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/matthieu/commentapi.aspx?PostID=1651289</wfw:comment><comments>http://msmvps.com/blogs/matthieu/archive/2008/10/19/ado-net-data-services-hooking-poc-v3-1.aspx#comments</comments><description>&lt;p&gt;I just finished implementing the IUpdatable interface&lt;img src="http://msmvps.com/emoticons/emotion-1.gif" alt="Smile" /&gt;&lt;/p&gt;
&lt;p&gt;With ADO.NET Data Services, in the client part, you can use some LINQ queries which will be translated to an url. It&amp;rsquo;s really great to be able to use LINQ. However, this query is restrictive. For example, extension methods defined in the&amp;nbsp;Queryable class aren&amp;rsquo;t allowed with ADO.NET Data Services (NotSupportedException).&lt;/p&gt;
&lt;p&gt;When you add a web reference&amp;nbsp;to your service, you will have some entity classes generated from the service metadata. If you have a relationship defined with a List&amp;lt;T&amp;gt;, or IEnumerable&amp;lt;T&amp;gt;, etc., in the server, the client generated code will use a System.Collections.ObjectModel.Collection. This class has a Count property. But when you want to use this on a LINQ query, you have a DataServiceQueryException. &lt;a target="_blank" href="http://www.codeplex.com/AstoriaHookingPOC"&gt;My ADO.NET Data Services Hooking POC&lt;/a&gt; solves it. &lt;img src="http://msmvps.com/emoticons/emotion-1.gif" alt="Smile" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1651289" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/matthieu/archive/tags/.Net/default.aspx">.Net</category><category domain="http://msmvps.com/blogs/matthieu/archive/tags/Entity+Framework+_2800_EF_2900_/default.aspx">Entity Framework (EF)</category><category domain="http://msmvps.com/blogs/matthieu/archive/tags/ADO.NET+Data+Services/default.aspx">ADO.NET Data Services</category><category domain="http://msmvps.com/blogs/matthieu/archive/tags/ADO.NET+Data+Services+Hooking+POC/default.aspx">ADO.NET Data Services Hooking POC</category></item><item><title>ADO.NET Data Services Hooking POC V3</title><link>http://msmvps.com/blogs/matthieu/archive/2008/10/17/ado-net-data-services-hooking-poc-v3.aspx</link><pubDate>Fri, 17 Oct 2008 15:58:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1651150</guid><dc:creator>Matthieu MEZIL</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/matthieu/rsscomments.aspx?PostID=1651150</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/matthieu/commentapi.aspx?PostID=1651150</wfw:comment><comments>http://msmvps.com/blogs/matthieu/archive/2008/10/17/ado-net-data-services-hooking-poc-v3.aspx#comments</comments><description>&lt;p&gt;&lt;a target="_blank" href="http://www.codeplex.com/AstoriaHookingPOC"&gt;The third version of my ADO.NET Data Services Hooking POC is released.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The IUpdatable interface is partially implemented. I am waiting for an answer to &lt;a target="_blank" href="http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=4013948&amp;amp;SiteID=1"&gt;my thread&lt;/a&gt; to implement ClearChanges and ResetResource methods.&lt;/p&gt;
&lt;p&gt;Note that it&amp;rsquo;s a POC, so my tests are very primitive. If you find a bug, let me know and please send me a code to reproduce it at matthieu.mezil at winwise.fr. &lt;/p&gt;
&lt;p&gt;I will use this post to answer some questions:&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;Why having a class hierarchy like this for my entities?&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;EmployeeBase (abstract)
&lt;ul&gt;
&lt;li&gt;Employee&lt;/li&gt;
&lt;li&gt;ManagerBase (abstract)
&lt;ul&gt;
&lt;li&gt;Manager&lt;/li&gt;
&lt;li&gt;TeamManager&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With ADO.NET Data Services, you can&amp;rsquo;t have inheritance between the classes you expose. So if you want to expose some employees and some managers, you can&amp;rsquo;t have Manager inheriting Employee.&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:underline;"&gt;Why defining relationships in the exposed classes and not in the base?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;An employee has a Manager property and a Manager has also a Manager property. But if you define the Manager property in EmployeeBase, &lt;a target="_blank" href="http://forums.microsoft.com/forums/ShowPost.aspx?PostID=3987682&amp;amp;SiteID=1"&gt;you have a NullReferenceException when you want to get the metadata&lt;/a&gt;. It&amp;rsquo;s a framework bug which will probably be fixed in next version.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1651150" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/matthieu/archive/tags/.Net/default.aspx">.Net</category><category domain="http://msmvps.com/blogs/matthieu/archive/tags/Entity+Framework+_2800_EF_2900_/default.aspx">Entity Framework (EF)</category><category domain="http://msmvps.com/blogs/matthieu/archive/tags/ADO.NET+Data+Services/default.aspx">ADO.NET Data Services</category><category domain="http://msmvps.com/blogs/matthieu/archive/tags/ADO.NET+Data+Services+Hooking+POC/default.aspx">ADO.NET Data Services Hooking POC</category></item><item><title>ADO.NET Data Services Hooking POC v2</title><link>http://msmvps.com/blogs/matthieu/archive/2008/10/08/ado-net-data-services-hooking-poc-v2.aspx</link><pubDate>Wed, 08 Oct 2008 08:23:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1650083</guid><dc:creator>Matthieu MEZIL</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/matthieu/rsscomments.aspx?PostID=1650083</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/matthieu/commentapi.aspx?PostID=1650083</wfw:comment><comments>http://msmvps.com/blogs/matthieu/archive/2008/10/08/ado-net-data-services-hooking-poc-v2.aspx#comments</comments><description>&lt;p&gt;I&amp;nbsp;continue&amp;nbsp;my &lt;a target="_blank" href="http://www.codeplex.com/AstoriaHookingPOC"&gt;POC&lt;/a&gt;&amp;nbsp;development. &lt;/p&gt;
&lt;p&gt;In my previous version, I didn&amp;#39;t supported keys in url. I do now. So I can do something like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://localhost:50683/WebDataService.svc/Teams(guid&amp;#39;adbae845-989e-4aae-8273-0b4325556812&amp;#39;)/Employees"&gt;http://localhost:50683/WebDataService.svc/Teams(guid&amp;#39;adbae845-989e-4aae-8273-0b4325556812&amp;#39;)/Employees&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I hope&amp;nbsp;this POC&amp;nbsp;will become more than&amp;nbsp;a POC. ADO.NET Data Services has some limitations with EF: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;EF limitations&amp;nbsp;&lt;/li&gt;
&lt;li&gt;ADO.NET Data Services&amp;nbsp;use the metadata, so if you add some properties on your entity types or on your context, ADO.NET Data Services ignore them&lt;/li&gt;
&lt;li&gt;&lt;a target="_blank" href="http://msmvps.com/blogs/matthieu/archive/2008/09/17/ado-net-data-services-with-inheritance-and-navigation-properties.aspx"&gt;the&amp;nbsp;&amp;quot;bug&amp;quot; which forbids relationships on children classes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;My POC tries to resolve these problems.&lt;/p&gt;
&lt;p&gt;The next version will probably implement the IUpdatable interface to allow data updates.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1650083" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/matthieu/archive/tags/.Net/default.aspx">.Net</category><category domain="http://msmvps.com/blogs/matthieu/archive/tags/Entity+Framework+_2800_EF_2900_/default.aspx">Entity Framework (EF)</category><category domain="http://msmvps.com/blogs/matthieu/archive/tags/ADO.NET+Data+Services/default.aspx">ADO.NET Data Services</category><category domain="http://msmvps.com/blogs/matthieu/archive/tags/ADO.NET+Data+Services+Hooking+POC/default.aspx">ADO.NET Data Services Hooking POC</category></item><item><title>ADO.NET Data Services Hooking POC</title><link>http://msmvps.com/blogs/matthieu/archive/2008/10/05/ado-net-data-services-hooking-poc.aspx</link><pubDate>Sun, 05 Oct 2008 16:59:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1649791</guid><dc:creator>Matthieu MEZIL</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/matthieu/rsscomments.aspx?PostID=1649791</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/matthieu/commentapi.aspx?PostID=1649791</wfw:comment><comments>http://msmvps.com/blogs/matthieu/archive/2008/10/05/ado-net-data-services-hooking-poc.aspx#comments</comments><description>&lt;p style="margin:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;span style="font-size:small;font-family:Calibri;"&gt;When you use ADO.NET Data Services, you will reduce the flow between the client and the server to get only the entities you really want. If you use EF with ADO.Net Data Services, you will also reduce the flow between the Server and the DB.&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;span style="font-size:small;font-family:Calibri;"&gt;EF (particularly in the first version) doesn&amp;rsquo;t support all cases. So sometimes, you need to develop your own entity classes which encapsulate your EF ones.&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;span style="font-size:small;font-family:Calibri;"&gt;In this case, with ADO.NET Data Services, the flow between the Server and the DB isn&amp;rsquo;t optimized. &lt;a target="_blank" href="http://www.codeplex.com/AstoriaHookingPOC"&gt;I made this POC to do this scenario.&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;span style="font-size:small;font-family:Calibri;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;span style="font-size:small;font-family:Calibri;"&gt;When I did it, I realized that the ADO.NET Data Services Framework is extremely closed and most of classes / interfaces / enums are internal. I think that something will change in V2. For example, you have an internal interface System.Data.Services.Providers.IDataServiceProvider only implemented by System.Data.Services.Providers.BaseServiceProvider which is an internal abstract class. I think in a future version, the interface will be public. Else I don&amp;rsquo;t understand why the interface is used for. &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;span style="font-size:small;font-family:Calibri;"&gt;To be able to hook the normal ADO.NET Data Services way, I have two choices: &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0cm 0cm 0pt 18pt;" class="MsoListBulletCxSpFirst"&gt;&lt;span style="font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;span style="font-size:small;"&gt;&amp;middot;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:small;font-family:Calibri;"&gt;I rewrite a lot of the ADO.NET Data Services internal classes&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:0cm 0cm 0pt 18pt;" class="MsoListBulletCxSpMiddle"&gt;&lt;span style="font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:Symbol;"&gt;&lt;span style="mso-list:Ignore;"&gt;&lt;span style="font-size:small;"&gt;&amp;middot;&lt;/span&gt;&lt;span style="font-family:&amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:small;font-family:Calibri;"&gt;I use, by reflection, the Internal classes&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin:10pt 0cm;text-indent:0cm;mso-add-space:auto;mso-list:none;tab-stops:36.0pt;" class="MsoListBulletCxSpLast"&gt;&lt;span style="font-size:small;font-family:Calibri;"&gt;The first choice is probably the best one because as the classes are internal, MS can change their members&amp;nbsp;in the future version but, as it&amp;rsquo;s just a POC, I choose the second choice which is fastest.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1649791" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/matthieu/archive/tags/.Net/default.aspx">.Net</category><category domain="http://msmvps.com/blogs/matthieu/archive/tags/Entity+Framework+_2800_EF_2900_/default.aspx">Entity Framework (EF)</category><category domain="http://msmvps.com/blogs/matthieu/archive/tags/ADO.NET+Data+Services/default.aspx">ADO.NET Data Services</category><category domain="http://msmvps.com/blogs/matthieu/archive/tags/ADO.NET+Data+Services+Hooking+POC/default.aspx">ADO.NET Data Services Hooking POC</category></item></channel></rss>