<?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>Shiju Varghese's Blog : LINQ</title><link>http://weblogs.asp.net/shijuvarghese/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>Goodbye Stored procedures, It’s the time to move on "Linq to Sql" </title><link>http://weblogs.asp.net/shijuvarghese/archive/2008/03/26/goodbye-stored-procedures-it-s-the-time-to-move-on-quot-linq-to-sql-quot.aspx</link><pubDate>Thu, 27 Mar 2008 03:45:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6035386</guid><dc:creator>shiju</dc:creator><author>shiju</author><slash:comments>11</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/shijuvarghese/rsscomments.aspx?PostID=6035386</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/shijuvarghese/commentapi.aspx?PostID=6035386</wfw:comment><comments>http://weblogs.asp.net/shijuvarghese/archive/2008/03/26/goodbye-stored-procedures-it-s-the-time-to-move-on-quot-linq-to-sql-quot.aspx#comments</comments><description>&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;A href="http://en.wikipedia.org/wiki/Object-relational_mapping" target=_blank mce_href="http://en.wikipedia.org/wiki/Object-relational_mapping"&gt;&lt;FONT face="Times New Roman"&gt;O/RM&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Times New Roman"&gt; &lt;STRONG&gt;Vs Stored Procedures. Which is the best approach?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;For the last few years, many developers and architects are&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;engage in a series of debates about ORM Vs Stored Procedures. Many of them argue for ORM and others are arguing for stored procedures.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;The interesting thing is that people with highly object orientation sense, recommends ORM. The J2EE community strongly recommending the ORM approaches instead of using stored procedures. Some .NET developers coming from Visual Basic 6.0 background supports stored procedures. Hibernate and NHibernate (.NET version of java version Hibernate) are the highly successful ORM that using both .NET and J2EE community. Then which is the best approach for data persist? Personally I hate stored procedures and strongly recommend for ORM instead of using the legacy stored procedure programming.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;STRONG&gt;Why I hate stored procedures?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 130%"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #333333; LINE-HEIGHT: 130%"&gt;&lt;FONT face="Times New Roman" color=#000000&gt;Stored Procedures are written by DB languages such as PL/SQL and T-SQL and this type of languages are not designed for writing business logic and debugging process is really a nightmare. And stored procedures hide the business logic and lacks readability of business process. If you are going to port DB from one RDBMS to another one, you have to re-write your all stored procedures. If you want to run your product on multiple databases, the ORM is the right approach. And ultimately the stored procedure restricts the proper business abstraction. Many people argue that stored procedure provides better performance than dynamic generated Sql from an ORM and people believed that all stored procedure are pre-compiled. According to Microsoft Sql Server documentation, Sql Server does cache the execution plan for stored procedure instead of pre-compiled. Have a look at the MSDN article &lt;A href="http://msdn2.microsoft.com/en-us/library/Aa175244(SQL.80).aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/Aa175244(SQL.80).aspx"&gt;Execution Plan Caching and Reuse&lt;/A&gt;.&amp;nbsp; And I believe that maintainability, scalability and proper abstraction are the key factors of enterprise applications. The ORM approach enables these benefits.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 130%"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #333333; LINE-HEIGHT: 130%"&gt;&lt;FONT face="Times New Roman" color=#000000&gt;If you are a .NET developer, there is happy news for you. A new ORM named Linq to Sql coming from the Redmond campus along with the .Net framework 3.5. &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;What is LINQ to SQL?&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;LINQ to SQL is an O/RM (object relational mapping) of the .NET Framework 3.5. It provides you to model&amp;nbsp;a relational database&amp;nbsp;using .NET classes.&amp;nbsp; You can then query the database using LINQ, as well as insert, update and delete data from it. LINQ to SQL supports all types of database objects such as views, and stored procedures and also transactions. It also provides an easy way to integrate data validation and business logic rules into your data model. Visual Studio 2008 provides a Linq to SQL designer that enables to model and visualize a database as a LINQ to SQL object model. You can create the all database representations using the Linq to SQL designer. With the Linq to SQL designer, you can drag and drop the tables into the Linq to SQL designer surface and can represent the relations between tables. Linq to SQL allows you to model classes that map to tables within&amp;nbsp;a database.&amp;nbsp; These classes are known as "Entity Classes" and instances of them are called "Entities".&amp;nbsp; Like other OR/Ms, the Linq to SQL OR/Ms will generate the SQL statements at the runtime when interacting with the Entity Classes.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;Lets look at the below business object that mapped the customers table using Linq to Sql.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=code style="MARGIN: 0cm 0cm 8pt 36pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;[&lt;SPAN style="COLOR: teal"&gt;Table&lt;/SPAN&gt;(Name=&lt;SPAN style="COLOR: maroon"&gt;"Customers"&lt;/SPAN&gt;)]&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;public class&lt;/SPAN&gt; &lt;SPAN style="COLOR: teal"&gt;Customer&lt;/SPAN&gt;&lt;BR&gt;{&lt;BR&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[&lt;SPAN style="COLOR: teal"&gt;Column&lt;/SPAN&gt;(Id=&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;)]&lt;BR&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; CustomerID;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=code style="MARGIN: 0cm 0cm 8pt 36pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[&lt;SPAN style="COLOR: teal"&gt;Column&lt;/SPAN&gt;]&lt;BR&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public string&lt;/SPAN&gt; CustomerName;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=code style="MARGIN: 0cm 0cm 8pt 36pt; TEXT-INDENT: 36pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;[&lt;SPAN style="COLOR: teal"&gt;Column&lt;/SPAN&gt;]&lt;BR&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public string&lt;/SPAN&gt; City;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=code style="MARGIN: 0cm 0cm 8pt 36pt; TEXT-INDENT: 36pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;[&lt;SPAN style="COLOR: teal"&gt;Column&lt;/SPAN&gt;]&lt;BR&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;public string&lt;/SPAN&gt; Phone;&lt;BR&gt;}&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;&amp;nbsp;After modeling the Database with Linq to Sql, we can do all DB operations against it. The below code is the query against Customer object that represents the Customer table.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=code style="MARGIN: 0cm 0cm 8pt 36pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: teal"&gt;DataContext&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt; db = &lt;SPAN style="COLOR: blue"&gt;new &lt;/SPAN&gt;&lt;SPAN style="COLOR: teal"&gt;DataContext(&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=code style="MARGIN: 0cm 0cm 8pt 36pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: blue"&gt;&lt;FONT face="Times New Roman"&gt;var&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt; q = &lt;SPAN style="COLOR: blue"&gt;from&lt;/SPAN&gt; c &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; db.Customer&lt;BR&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;where&lt;/SPAN&gt; c.City == &lt;SPAN style="COLOR: #993300"&gt;"Cochin"&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;select&lt;/SPAN&gt; c;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;In the above query will select customers of city Cochin .The DataContext represent an abstraction of your database.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;The below code is update existing customer&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #2b91af"&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;DataClassesDataContext&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt; db=&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DataClassesDataContext&lt;/SPAN&gt;();&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt; cust=db.Customer.Single(c=&amp;gt; c.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;CustomerID&lt;SPAN&gt; ==”&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;C101&lt;/SPAN&gt;&lt;SPAN&gt;”);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;cust.Phone=&lt;SPAN style="COLOR: #a31515"&gt;"919847059589"&lt;/SPAN&gt;;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;db.SubmitChanges();&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;The below code is add new customer&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #2b91af"&gt;DataClassesDataContext&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt; db=&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DataClassesDataContext&lt;/SPAN&gt;();&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt; cust=new &lt;SPAN style="COLOR: #2b91af"&gt;Customer();&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;Cust.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt; CustomerName=”ABC Ltd”&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;cust&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;.City=”Mumbai”;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;cust.Phone=”&lt;SPAN style="COLOR: #a31515"&gt;919847059589&lt;/SPAN&gt;”;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;db.Customer.Add(cust);&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: green"&gt;db.SubmitChanges();&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;The below code is delete customer&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #2b91af"&gt;DataClassesDataContext&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt; db=&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DataClassesDataContext&lt;/SPAN&gt;();&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #2b91af"&gt;Customer&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt; cust=db.Customer.Single(c=&amp;gt; c.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;CustomerID&lt;SPAN&gt; ==”&lt;/SPAN&gt;&lt;SPAN style="COLOR: maroon"&gt;C101&lt;/SPAN&gt;&lt;SPAN&gt;”);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;Db.Customer.Remove(cust);&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;The below code is using a join query&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: blue"&gt;&lt;FONT face="Times New Roman"&gt;var&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt; orders =&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;from&lt;/SPAN&gt; o &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; db.Orders&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;join&lt;/SPAN&gt; c &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; db.Customer &lt;SPAN style="COLOR: blue"&gt;on&lt;/SPAN&gt; o.CustomerID &lt;SPAN style="COLOR: blue"&gt;equals&lt;/SPAN&gt; c.CustomerID&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;where&lt;/SPAN&gt; c.CustomerID == &lt;SPAN style="COLOR: maroon"&gt;"C101"&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN style="COLOR: blue"&gt;select&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; {c.CustomerName, o.ShipName, o.ShipAddress };&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;&lt;SPAN style="FONT-SIZE: 11pt"&gt;&lt;FONT face="Times New Roman"&gt;Linq to Sql is an exciting ORM tool from Microsoft and I hope that people will use this ORM along with .NET 3.5 applications.&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6035386" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/shijuvarghese/archive/tags/.Net+3.5/default.aspx">.Net 3.5</category><category domain="http://weblogs.asp.net/shijuvarghese/archive/tags/LINQ/default.aspx">LINQ</category></item></channel></rss>