<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/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>Runtime Debugger - kannan M ambadi's blog : LINQ</title><link>http://weblogs.asp.net/kannanambadi/archive/tags/LINQ/default.aspx</link><description>Tags: LINQ</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>ORM Technology - nHibernate vs Linq </title><link>http://weblogs.asp.net/kannanambadi/archive/2009/01/16/orm-technology.aspx</link><pubDate>Fri, 16 Jan 2009 04:39:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6837728</guid><dc:creator>kannan.ambadi</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/kannanambadi/rsscomments.aspx?PostID=6837728</wfw:commentRss><comments>http://weblogs.asp.net/kannanambadi/archive/2009/01/16/orm-technology.aspx#comments</comments><description>&lt;p&gt;I'm back after some time away from my blog ;).. This time i would like to tell about my favourite "nHibernate" and ORM Technology.&amp;nbsp; Not So Long Ago,&amp;nbsp; &lt;font size="2" face="Trebuchet MS"&gt;i’ve attended a microsoft seminar on Visual Studio 2008 &amp;amp; &lt;a href="http://msdn2.microsoft.com/en-us/teamsystem/default.aspx" mce_href="http://msdn2.microsoft.com/en-us/teamsystem/default.aspx" title="Visual Studio Team System" target="_blank"&gt;VSTS&lt;/a&gt;.
It was a nice presentation and we have had a delicious lunch
too;)…Presentation on VSTS was amazing. The presenter, Tejsvi
Kumar(Technology specialist from microsoft) , who provided clear idea
on how we can handle a big project by &lt;b&gt;Only &lt;/b&gt;using VSTS.Then he
had shown demo on VSTS how Project manager can assign tasks, view
status or create test cases on the fly etc. In between he also
mentioned on visual studio 2008 features. i would to like express my
appreciation to them for sharing their exp with us. And more than that,
they’ve come up with more knowledge by replying our queries. Me too
sent a mail regarding some queries on LINQ. I got a very detailed reply
on this. I would like to share their reply with everyone since it
provides a neat explaination on LINQ n other technologies.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Trebuchet MS"&gt;&lt;b&gt;Q :&lt;/b&gt; &lt;i&gt;Can u differentiate between Ado.Net and LINQ&lt;/i&gt;&lt;br&gt;
&lt;b&gt; A :&lt;/b&gt; ADO.NET is a mechanism to connect to the data source (like
ODBC) whereas LINQ is a query mechanism to query *any* kind of data not
necessarily data from a database. As an example try the following
simple LINQ program:&lt;/font&gt;&lt;/p&gt;
&lt;div style="margin-left: 40px;"&gt;&lt;font size="2" face="Trebuchet MS"&gt;        static void Main(string[] args)&lt;br&gt;
{&lt;br&gt;
int[] numbers = { 3, 5, 6, 1 };&lt;/font&gt;&lt;/div&gt;
&lt;div style="margin-left: 40px;"&gt;&lt;font size="2" face="Trebuchet MS"&gt;var exp = from n in numbers&lt;/font&gt;&lt;/div&gt;
&lt;div style="margin-left: 40px;"&gt;&lt;font size="2" face="Trebuchet MS"&gt;                                  where n &amp;lt; 5&lt;br&gt;
orderby n ascending&lt;br&gt;
select n;&lt;/font&gt;&lt;font size="2" face="Trebuchet MS"&gt;foreach(var e in exp )&lt;br&gt;
{&lt;br&gt;
Console.WriteLine(e);&lt;br&gt;
}&lt;br&gt;
}&lt;/font&gt;&lt;/div&gt;
&lt;p&gt;&lt;font size="2" face="Trebuchet MS"&gt;This program demonstrates the following:&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Trebuchet MS"&gt;	- LINQ is a language concept (integrating queries in the programming language)&lt;br&gt;
- LINQ queries can be quite expressive including joins, where clauses, grouping etc.&lt;br&gt;
- LINQ has nothing to do with databases in particular – however you can
build LINQ based extensions that enable you to to query any kind of
database using LINQ queries (e.g. LINQ to XML, LINQ to SQL, LINQ to
datasets, LINQ to Entities, LINQ to Objects) &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Trebuchet MS"&gt;&lt;b&gt;Q : &lt;/b&gt;&lt;i&gt;Is LINQ is nothing but a copy of nHiberante ?&lt;/i&gt;&lt;br&gt;
&lt;b&gt; A :&lt;/b&gt; I disagree - LINQ is NOT copied from nHiberbate. The
example in point 1 will explain that nHibernate has nothing similar.
However you can definitely compare LINQ-to-SQL with nHibernate. Now
nHibernate itself is no new technology – both nHibernate and
LINQ-to-SQL are products that make use of the Object Relational Mapping
(ORM) Technology. There are pro and cons of ORM technology and they are
very widely discussed in the technology circles. You can get an insight
into them on the net. The important thing to remember is that there are
definitely some very important benefits (inspite of some disadvantages)
of ORMs and if as an architect your analysis proves that ORM wil
benefit your project you should go for it. Generally every technology
has its pros and cons (like any other thing in life) and as a smart
Architect you need to understand your requirements in nicely and then
choose the technology that suits you best. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Trebuchet MS"&gt;&lt;b&gt;Q :&lt;/b&gt;&lt;i&gt; LINQ(nHiberante) causes difficulty while debugging the code. Its very difficult to find which line throws exception.&lt;/i&gt;&lt;br&gt;
&lt;b&gt; A :&lt;/b&gt; This statement confirms my comment in point 3. Pro of
LINQ-to-SQL(nHibernate) – faster code development; Con of LINQ-to-SQL
(nHibernate) – possibly more extensive debugging. However, if you make
you of some best practices for debugging you can reduce the time. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Trebuchet MS"&gt;&lt;b&gt;Q :&lt;/b&gt;&lt;i&gt; Its very difficult to make changes according to Database changes..&lt;/i&gt;&lt;br&gt;
&lt;b&gt; A :&lt;/b&gt; Actually, with ORMs it becomes easier to abstract the
Database changes from Application changes. So if your application is
architected correctly and there are DB changes – with LINQ-to-SQL (or
nHibernate) you will need to do NO or almost minimum changes in your
code (all you have to do is change the mapping layer) &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2" face="Trebuchet MS"&gt;&lt;b&gt;Q : &lt;/b&gt;&lt;i&gt;Performance is slow compared to ado.Net(i’ve checked wit nHibernate, not wit LINQ)&lt;/i&gt;&lt;br&gt;
&lt;b&gt; A :&lt;/b&gt; Please read my blog post on performance generally:
http://blogs.msdn.com/bsinghal/archive/2007/07/16/there-is-a-performance-problem.aspx.&lt;br&gt;
To compare the performance of LINQ v/s non-LINQ scenario – you will
need to do very thorough testing and make sure that we compare apples
to apples.Regarding performance is slow with nHibernate or LINQ-to-SQL
(ORMs) as compared to ADO.NET – yes that can be true in some cases even
after doing all the possible optimizations etc because ORMs do add an
extra layer of processing but they provide a lot of flexibility in
return. The point here is that one should analyse the technology
properly and make sure that any technology they choose addresses their
requirements and needs. So if you are ready to spend 10 times more time
in developing the application in ADO.NET at the cost of gaining lets
say 2% performance improvement and of that is of more importance for
your business then yes using ADO.NET is better.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6837728" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Asp.Net/default.aspx">Asp.Net</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/C_2300_+2.0/default.aspx">C# 2.0</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/linq-to-sql/default.aspx">linq-to-sql</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Ado.Net/default.aspx">Ado.Net</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/vsts/default.aspx">vsts</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/microsoft/default.aspx">microsoft</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/visual+studio/default.aspx">visual studio</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Asp.Net+2.0/default.aspx">Asp.Net 2.0</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/.NET+3.5/default.aspx">.NET 3.5</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/.NET+2.0/default.aspx">.NET 2.0</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/ASP.NET+3.5/default.aspx">ASP.NET 3.5</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/.net+development/default.aspx">.net development</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/.NET+Framework/default.aspx">.NET Framework</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/nHibernate/default.aspx">nHibernate</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Web+2.0/default.aspx">Web 2.0</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Web+Development/default.aspx">Web Development</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/ORM+Architecture/default.aspx">ORM Architecture</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Tools/default.aspx">Tools</category><category domain="http://weblogs.asp.net/kannanambadi/archive/tags/Architecture/default.aspx">Architecture</category></item></channel></rss>