<?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: Do you really need a data access layer with LINQ?</title>
	<atom:link href="http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html</link>
	<description>Productive software development using ASP.NET, C#, Adobe Flex, and other technologies and tools.</description>
	<lastBuildDate>Fri, 12 Mar 2010 14:26:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Carlos ABS</title>
		<link>http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html/comment-page-1#comment-1568</link>
		<dc:creator>Carlos ABS</dc:creator>
		<pubDate>Fri, 14 Aug 2009 14:15:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html#comment-1568</guid>
		<description>Hi!

I&#039;m developing a brand nem e-commerce website and had the same insight.

I was developing in the &quot;old way&quot;:

U.I. -&gt; B.O.L. -&gt; D.A.L -&gt; Stored procedures

Then i was introduced to LINQ and the more i used it, the more i realized that my DAL, BOL and stored procedures, IN THIS CASE, are useless.

I&#039;m not 100% sure about this, but i&#039;m planning to remove all those &quot;useless&quot; and work just with LINQ by now.

I used a third part objects/procedures generator but LINQ to SQL is doing the &quot;dirt work&quot; for me now.</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>I&#8217;m developing a brand nem e-commerce website and had the same insight.</p>
<p>I was developing in the &#8220;old way&#8221;:</p>
<p>U.I. -&gt; B.O.L. -&gt; D.A.L -&gt; Stored procedures</p>
<p>Then i was introduced to LINQ and the more i used it, the more i realized that my DAL, BOL and stored procedures, IN THIS CASE, are useless.</p>
<p>I&#8217;m not 100% sure about this, but i&#8217;m planning to remove all those &#8220;useless&#8221; and work just with LINQ by now.</p>
<p>I used a third part objects/procedures generator but LINQ to SQL is doing the &#8220;dirt work&#8221; for me now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl Kemerait</title>
		<link>http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html/comment-page-1#comment-1289</link>
		<dc:creator>Karl Kemerait</dc:creator>
		<pubDate>Wed, 14 Jan 2009 13:43:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html#comment-1289</guid>
		<description>Nice thought process, in general I agree with you, I would even sugest that we could go further. I tend to think the most of the &quot;best practices&quot; that follow today are designed to be &quot;best proactices&quot; for applications that are much larger than the one we typically work on. I think it&#039;s time to look at a second set of &quot;best practices&quot; that more closely matches our daily tasks and priorities.

http://designlunacy.blogspot.com

for my latest rant on &quot;involving users in design&quot;</description>
		<content:encoded><![CDATA[<p>Nice thought process, in general I agree with you, I would even sugest that we could go further. I tend to think the most of the &#8220;best practices&#8221; that follow today are designed to be &#8220;best proactices&#8221; for applications that are much larger than the one we typically work on. I think it&#8217;s time to look at a second set of &#8220;best practices&#8221; that more closely matches our daily tasks and priorities.</p>
<p><a href="http://designlunacy.blogspot.com" rel="nofollow" onclick="pageTracker._trackPageview('/outgoing/designlunacy.blogspot.com?referer=');">http://designlunacy.blogspot.com</a></p>
<p>for my latest rant on &#8220;involving users in design&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dew Drop - May 8, 2008 &#124; Alvin Ashcraft's Morning Dew</title>
		<link>http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html/comment-page-1#comment-245</link>
		<dc:creator>Dew Drop - May 8, 2008 &#124; Alvin Ashcraft's Morning Dew</dc:creator>
		<pubDate>Thu, 08 May 2008 13:16:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html#comment-245</guid>
		<description>[...] Do You Really Need a Data Access Layer with LINQ? (Jason Young) [...]</description>
		<content:encoded><![CDATA[<p>[...] Do You Really Need a Data Access Layer with LINQ? (Jason Young) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: teedyay</title>
		<link>http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html/comment-page-1#comment-243</link>
		<dc:creator>teedyay</dc:creator>
		<pubDate>Thu, 08 May 2008 09:49:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html#comment-243</guid>
		<description>Mmm, thanks for the popcorn, Will! ;-)

There&#039;s some quite strong opinions on this page, but I can see where you&#039;re coming from: LINQ makes it so damn easy to write queries in the code behind your page, but something makes me feel a little uncomfortable doing that.

Just lately I&#039;ve been trying to put most (all?) of the DB-accessing LINQ queries into the non-generated half of my DataContext class, just so it&#039;s all together in one place, giving me my data access layer.

This is fine for encapsulation, but feels a bit like over-engineering when it&#039;s a simple query I only use on one page.

LINQ&#039;s DataContext has been quite a paradigm shift for me in terms of how I use ORM. For me at least, the jury&#039;s still out on issues like this.</description>
		<content:encoded><![CDATA[<p>Mmm, thanks for the popcorn, Will! <img src='http://www.ytechie.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>There&#8217;s some quite strong opinions on this page, but I can see where you&#8217;re coming from: LINQ makes it so damn easy to write queries in the code behind your page, but something makes me feel a little uncomfortable doing that.</p>
<p>Just lately I&#8217;ve been trying to put most (all?) of the DB-accessing LINQ queries into the non-generated half of my DataContext class, just so it&#8217;s all together in one place, giving me my data access layer.</p>
<p>This is fine for encapsulation, but feels a bit like over-engineering when it&#8217;s a simple query I only use on one page.</p>
<p>LINQ&#8217;s DataContext has been quite a paradigm shift for me in terms of how I use ORM. For me at least, the jury&#8217;s still out on issues like this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: superjason</title>
		<link>http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html/comment-page-1#comment-242</link>
		<dc:creator>superjason</dc:creator>
		<pubDate>Thu, 08 May 2008 01:35:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html#comment-242</guid>
		<description>&quot;Eventually you’ll come to the realization that common linq queries belong in a common class accessed by all pages&quot; - I agree, but what I&#039;ve seen, at least on the last site, common queries are more rare than I would like. Each page usually has different requirements. When I&#039;m writing code, I&#039;m very conscious of rewriting the same functionality. When that happens, of course I&#039;m going to try to re-use my code.

Chad, I agree. I think I&#039;ve unsuccessfully conveyed the situation that I&#039;ve run into. I&#039;ve tried to apply my background in large application development, to individual pages with their own unique functionality. I don&#039;t regret insulting people, since I was including myself in that group. I&#039;m simply suggesting that a hard and fast rule of trying desperately to separate out DAL logic might not reap the benefits we would expect. 

In the site I just created, I had all the layers, and they were completely separated. I was able to test any layer regardless of the other layers. The site is reliable thanks to 700 unit tests, but at the expense of having 10x as much code to maintain. Am I really better off? I&#039;m not so sure!

Honestly, I would have rather saved all of that time, and spent it on the critical pages. For example, I would have liked to had a full MVC unit testable checkout process.</description>
		<content:encoded><![CDATA[<p>&#8220;Eventually you’ll come to the realization that common linq queries belong in a common class accessed by all pages&#8221; &#8211; I agree, but what I&#8217;ve seen, at least on the last site, common queries are more rare than I would like. Each page usually has different requirements. When I&#8217;m writing code, I&#8217;m very conscious of rewriting the same functionality. When that happens, of course I&#8217;m going to try to re-use my code.</p>
<p>Chad, I agree. I think I&#8217;ve unsuccessfully conveyed the situation that I&#8217;ve run into. I&#8217;ve tried to apply my background in large application development, to individual pages with their own unique functionality. I don&#8217;t regret insulting people, since I was including myself in that group. I&#8217;m simply suggesting that a hard and fast rule of trying desperately to separate out DAL logic might not reap the benefits we would expect. </p>
<p>In the site I just created, I had all the layers, and they were completely separated. I was able to test any layer regardless of the other layers. The site is reliable thanks to 700 unit tests, but at the expense of having 10x as much code to maintain. Am I really better off? I&#8217;m not so sure!</p>
<p>Honestly, I would have rather saved all of that time, and spent it on the critical pages. For example, I would have liked to had a full MVC unit testable checkout process.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad Myers</title>
		<link>http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html/comment-page-1#comment-241</link>
		<dc:creator>Chad Myers</dc:creator>
		<pubDate>Wed, 07 May 2008 23:57:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html#comment-241</guid>
		<description>@superjason: Stop insulting people (re: hammer/nail) and try to consider why the &#039;db.Orders&#039; might be a problem if you ever wanted to use that code against something other than a database (i.e. test data). If you&#039;re happy with tightly binding all your code to your database and sure that you&#039;ll never re-use that code for anything else, then why do any layers and just have one solid layer and put everything in the code behind or directly in the view?</description>
		<content:encoded><![CDATA[<p>@superjason: Stop insulting people (re: hammer/nail) and try to consider why the &#8216;db.Orders&#8217; might be a problem if you ever wanted to use that code against something other than a database (i.e. test data). If you&#8217;re happy with tightly binding all your code to your database and sure that you&#8217;ll never re-use that code for anything else, then why do any layers and just have one solid layer and put everything in the code behind or directly in the view?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: logicalmind</title>
		<link>http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html/comment-page-1#comment-240</link>
		<dc:creator>logicalmind</dc:creator>
		<pubDate>Wed, 07 May 2008 22:17:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html#comment-240</guid>
		<description>It all depends on project size. If you are a single developer writing all the code and all the pages then of course it&#039;s going to be easiest for you to write the least amount of code. Once you introduce more developers to the project that starts to fall apart. 

Are you suggesting that whoever is writing a page determine what linq queries they use and just write those in their page? Eventually you&#039;ll come to the realization that common linq queries belong in a common class accessed by all pages. Separate people can write these separate layers as would be the case in projects with more than one developer. Once you do this you&#039;re back to where you started except you&#039;ve replaced nhibernate data access layer with linq for sql data access layer.</description>
		<content:encoded><![CDATA[<p>It all depends on project size. If you are a single developer writing all the code and all the pages then of course it&#8217;s going to be easiest for you to write the least amount of code. Once you introduce more developers to the project that starts to fall apart. </p>
<p>Are you suggesting that whoever is writing a page determine what linq queries they use and just write those in their page? Eventually you&#8217;ll come to the realization that common linq queries belong in a common class accessed by all pages. Separate people can write these separate layers as would be the case in projects with more than one developer. Once you do this you&#8217;re back to where you started except you&#8217;ve replaced nhibernate data access layer with linq for sql data access layer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: superjason</title>
		<link>http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html/comment-page-1#comment-239</link>
		<dc:creator>superjason</dc:creator>
		<pubDate>Wed, 07 May 2008 21:47:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html#comment-239</guid>
		<description>Our business objects match our database. It was written from the ground up that way. We use OR-mappers exclusively.

Code changes will trigger compile errors (when using Linq), and we&#039;ll know where to make the changes.

I&#039;ll check out the Linq screencast you mentioned. I would like to see a good ecommerce example.</description>
		<content:encoded><![CDATA[<p>Our business objects match our database. It was written from the ground up that way. We use OR-mappers exclusively.</p>
<p>Code changes will trigger compile errors (when using Linq), and we&#8217;ll know where to make the changes.</p>
<p>I&#8217;ll check out the Linq screencast you mentioned. I would like to see a good ecommerce example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paco</title>
		<link>http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html/comment-page-1#comment-238</link>
		<dc:creator>Paco</dc:creator>
		<pubDate>Wed, 07 May 2008 21:40:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html#comment-238</guid>
		<description>The main point is that the structure of your business objects is not the same as the structure of your database in 90% of the situations. And if the structure is the same now, you probably don&#039;t want to change the UI code after every minor change in the database. Of course you can solve this problem by writing the Linq XML or [attributes] yourself instead of using the designer, but then you are back to the same difficulties as when you used NHibernate.

The main point about Linq is the delayed execution.
Have you seen the screencast of Rob Conery?
He has a nice way to seperate those things and also uses an ecomerce site as example.

I have also tried Rails. A dissapoint was I have to write 3 times more unit test then in C#, because a compiler already checks a lot of stuff.</description>
		<content:encoded><![CDATA[<p>The main point is that the structure of your business objects is not the same as the structure of your database in 90% of the situations. And if the structure is the same now, you probably don&#8217;t want to change the UI code after every minor change in the database. Of course you can solve this problem by writing the Linq XML or [attributes] yourself instead of using the designer, but then you are back to the same difficulties as when you used NHibernate.</p>
<p>The main point about Linq is the delayed execution.<br />
Have you seen the screencast of Rob Conery?<br />
He has a nice way to seperate those things and also uses an ecomerce site as example.</p>
<p>I have also tried Rails. A dissapoint was I have to write 3 times more unit test then in C#, because a compiler already checks a lot of stuff.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: superjason</title>
		<link>http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html/comment-page-1#comment-237</link>
		<dc:creator>superjason</dc:creator>
		<pubDate>Wed, 07 May 2008 19:33:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.ytechie.com/2008/05/do-you-really-need-a-data-access-layer-with-linq.html#comment-237</guid>
		<description>Maybe I&#039;m just not understanding, but consider the following query:

var orders = from order in db.Orders
where order.Type == 5
select order;

How can it possibly be beneficial to move that into a data access layer?

I probably should have described the scenario a little better. This is an e-commerce site that has dozens of pages, and they all work quite differently. I&#039;ve bought into the whole layered approach, defining a data model, using NHibernate, etc. I live it every day. I get frustrated when a page with 4 drop down lists takes 5-10 hours because I have to do this:
- Create my NHibernate queries in my data access layer
- Write unit tests for those queries
- Call those DAL queries from the UI (with the hundreds of other queries in there)
- Debug it if it doesn&#039;t work

Then, I have to do it all again to save it. There is SO much code I now have to maintain, and I don&#039;t see how it&#039;s worth it.

How can replacing 20 lines of code with 3 lines of LINQ not be beneficial? I can write the 3 lines of code in 30 seconds, and test it in another 30. That gives me time to make my DAL better for the times when I actually need it.

As I mentioned, this probably doesn&#039;t apply to non-trivial examples.

The point is that some people seem to be too stuck in their old ways of thinking. My background is in enterprise applications, but the simplicity of some of the RoR and DJango code made me jealous, and opened my eyes.

When you have a hammer, everything looks like a nail.</description>
		<content:encoded><![CDATA[<p>Maybe I&#8217;m just not understanding, but consider the following query:</p>
<p>var orders = from order in db.Orders<br />
where order.Type == 5<br />
select order;</p>
<p>How can it possibly be beneficial to move that into a data access layer?</p>
<p>I probably should have described the scenario a little better. This is an e-commerce site that has dozens of pages, and they all work quite differently. I&#8217;ve bought into the whole layered approach, defining a data model, using NHibernate, etc. I live it every day. I get frustrated when a page with 4 drop down lists takes 5-10 hours because I have to do this:<br />
- Create my NHibernate queries in my data access layer<br />
- Write unit tests for those queries<br />
- Call those DAL queries from the UI (with the hundreds of other queries in there)<br />
- Debug it if it doesn&#8217;t work</p>
<p>Then, I have to do it all again to save it. There is SO much code I now have to maintain, and I don&#8217;t see how it&#8217;s worth it.</p>
<p>How can replacing 20 lines of code with 3 lines of LINQ not be beneficial? I can write the 3 lines of code in 30 seconds, and test it in another 30. That gives me time to make my DAL better for the times when I actually need it.</p>
<p>As I mentioned, this probably doesn&#8217;t apply to non-trivial examples.</p>
<p>The point is that some people seem to be too stuck in their old ways of thinking. My background is in enterprise applications, but the simplicity of some of the RoR and DJango code made me jealous, and opened my eyes.</p>
<p>When you have a hammer, everything looks like a nail.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
