<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
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/"
> <channel><title>Comments on: Your Data Retrieval Code Should Be Readable Too</title> <atom:link href="http://davybrion.com/blog/2009/03/your-data-retrieval-code-should-be-readable-too/feed/" rel="self" type="application/rss+xml" /><link>http://davybrion.com/blog/2009/03/your-data-retrieval-code-should-be-readable-too/</link> <description>inquisitive: adjective. given to inquiry, research, or asking questions; eager for knowledge; intellectually curious</description> <lastBuildDate>Wed, 08 Feb 2012 11:42:42 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Weekly Links #44 &#124; GrantPalin.com</title><link>http://davybrion.com/blog/2009/03/your-data-retrieval-code-should-be-readable-too/comment-page-1/#comment-9952</link> <dc:creator>Weekly Links #44 &#124; GrantPalin.com</dc:creator> <pubDate>Mon, 16 Mar 2009 02:30:53 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1072#comment-9952</guid> <description>[...] Your Data Retrieval Code Should Be Readable Too Good advice from Davy Brion. [...]</description> <content:encoded><![CDATA[<p>[...] Your Data Retrieval Code Should Be Readable Too Good advice from Davy Brion. [...]</p> ]]></content:encoded> </item> <item><title>By: Neal Blomfield</title><link>http://davybrion.com/blog/2009/03/your-data-retrieval-code-should-be-readable-too/comment-page-1/#comment-9679</link> <dc:creator>Neal Blomfield</dc:creator> <pubDate>Wed, 11 Mar 2009 01:15:38 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1072#comment-9679</guid> <description>Might not need the Lambda Extensions if the work on the AST is completed ( no idea what the timeframe on that is ), we&#039;ll just be able to bang out some good old fashioned LINQ =D</description> <content:encoded><![CDATA[<p>Might not need the Lambda Extensions if the work on the AST is completed ( no idea what the timeframe on that is ), we&#8217;ll just be able to bang out some good old fashioned LINQ =D</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/03/your-data-retrieval-code-should-be-readable-too/comment-page-1/#comment-9660</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Tue, 10 Mar 2009 20:23:23 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1072#comment-9660</guid> <description>yeah those lambda extensions are really nice, and if i&#039;m not mistaken they will be included in NHibernate _after_ the 2.1 release (which might be NH3 but not sure on this)but i generally stick with what&#039;s in NH core</description> <content:encoded><![CDATA[<p>yeah those lambda extensions are really nice, and if i&#8217;m not mistaken they will be included in NHibernate _after_ the 2.1 release (which might be NH3 but not sure on this)</p><p>but i generally stick with what&#8217;s in NH core</p> ]]></content:encoded> </item> <item><title>By: Neal Blomfield</title><link>http://davybrion.com/blog/2009/03/your-data-retrieval-code-should-be-readable-too/comment-page-1/#comment-9659</link> <dc:creator>Neal Blomfield</dc:creator> <pubDate>Tue, 10 Mar 2009 20:19:00 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1072#comment-9659</guid> <description>Hmm, a few missing bits in that query - I forgot to encode the &lt; / &gt;=S</description> <content:encoded><![CDATA[<p>Hmm, a few missing bits in that query &#8211; I forgot to encode the &lt; / &gt;</p><p>=S</p> ]]></content:encoded> </item> <item><title>By: Neal Blomfield</title><link>http://davybrion.com/blog/2009/03/your-data-retrieval-code-should-be-readable-too/comment-page-1/#comment-9658</link> <dc:creator>Neal Blomfield</dc:creator> <pubDate>Tue, 10 Mar 2009 20:17:31 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1072#comment-9658</guid> <description>Not sure if you have tried NHibernate Lambda Extensions but they clean up the queries even more (and make them typesafe as well!)Using your example above, it would translate as soemthing like the following (without a test I wouldn&#039;t be 100% certain)&lt;code&gt;
Team teamAlias = null;
var teamIdsForUser = DetachedCriteria.For()
.Add(u =&gt; u.Id == userId)
.CreateAlias( u =&gt; u.Teams, () =&gt; teamAlias )
.SetProjection( LambdaProjection.Property( () =&gt; teamAlias.Id ) );Incident incidentAlias = null;
Configuration configurationAlias = null;
Structure structureAlias = null;
var incidents = Session.CreateCriteria(typeof(Incident), () =&gt; incidentAlias)
.CreateCriteria( () =&gt; incidentAlias.Configurations, () =&gt; configurationAlias, JoinType.InnerJoin)
.CreateCriteria(() =&gt; configurationAlias.Structure, () =&gt; structureAlias, JoinType.InnerJoin)
.Add(LambdaSubquery.Propery( () =&gt; configurationAlias.OrganisationalItem.Id ).In( teamIdsForUser ))
.Add( () =&gt; incidentAlias.ApprovedPhase == structureAlias.Phase )
.Add(SqlExpression.IsNull( () =&gt; incident.EndDate )
.SetResultTransformer(CriteriaSpecification.DistinctRootEntity)
.List();
&lt;/code&gt;http://code.google.com/p/nhlambdaextensions/</description> <content:encoded><![CDATA[<p>Not sure if you have tried NHibernate Lambda Extensions but they clean up the queries even more (and make them typesafe as well!)</p><p>Using your example above, it would translate as soemthing like the following (without a test I wouldn&#8217;t be 100% certain)</p><p><code><br
/> Team teamAlias = null;<br
/> var teamIdsForUser = DetachedCriteria.For()<br
/> .Add(u =&gt; u.Id == userId)<br
/> .CreateAlias( u =&gt; u.Teams, () =&gt; teamAlias )<br
/> .SetProjection( LambdaProjection.Property( () =&gt; teamAlias.Id ) );</p><p>Incident incidentAlias = null;<br
/> Configuration configurationAlias = null;<br
/> Structure structureAlias = null;<br
/> var incidents = Session.CreateCriteria(typeof(Incident), () =&gt; incidentAlias)<br
/> .CreateCriteria( () =&gt; incidentAlias.Configurations, () =&gt; configurationAlias, JoinType.InnerJoin)<br
/> .CreateCriteria(() =&gt; configurationAlias.Structure, () =&gt; structureAlias, JoinType.InnerJoin)<br
/> .Add(LambdaSubquery.Propery( () =&gt; configurationAlias.OrganisationalItem.Id ).In( teamIdsForUser ))<br
/> .Add( () =&gt; incidentAlias.ApprovedPhase == structureAlias.Phase )<br
/> .Add(SqlExpression.IsNull( () =&gt; incident.EndDate )<br
/> .SetResultTransformer(CriteriaSpecification.DistinctRootEntity)<br
/> .List();<br
/> </code></p><p><a
href="http://code.google.com/p/nhlambdaextensions/" rel="nofollow">http://code.google.com/p/nhlambdaextensions/</a></p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/03/your-data-retrieval-code-should-be-readable-too/comment-page-1/#comment-9629</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Tue, 10 Mar 2009 06:47:44 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1072#comment-9629</guid> <description>i did... from the post:&quot;You can hide the complexity of those queries in views or stored procedures but by doing that, you’re moving some very important details outside of your code. You’re introducing one more little hurdle the next developer will have to get over when trying to comprehend a certain piece of code which has to use that view or that stored procedure.&quot;though i have used both to deal with complex queries, i don&#039;t think it&#039;s a good solution</description> <content:encoded><![CDATA[<p>i did&#8230; from the post:</p><p>&#8220;You can hide the complexity of those queries in views or stored procedures but by doing that, you’re moving some very important details outside of your code. You’re introducing one more little hurdle the next developer will have to get over when trying to comprehend a certain piece of code which has to use that view or that stored procedure.&#8221;</p><p>though i have used both to deal with complex queries, i don&#8217;t think it&#8217;s a good solution</p> ]]></content:encoded> </item> <item><title>By: anon</title><link>http://davybrion.com/blog/2009/03/your-data-retrieval-code-should-be-readable-too/comment-page-1/#comment-9628</link> <dc:creator>anon</dc:creator> <pubDate>Tue, 10 Mar 2009 06:42:56 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=1072#comment-9628</guid> <description>Did you think about using Views to make the data access easier to read?</description> <content:encoded><![CDATA[<p>Did you think about using Views to make the data access easier to read?</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 2/11 queries in 0.005 seconds using disk: basic
Object Caching 416/417 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: d18sni7re4ly7f.cloudfront.net

Served from: davybrion.com @ 2012-02-09 03:08:04 -->
