<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblogcasts.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>Simons SQL Blog : Entity framework</title><link>http://sqlblogcasts.com/blogs/simons/archive/tags/Entity+framework/default.aspx</link><description>Tags: Entity framework</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Entity framework support for table valued functions and thus full text</title><link>http://sqlblogcasts.com/blogs/simons/archive/2011/01/30/entity-framework-support-for-table-valued-functions-and-thus-full-text.aspx</link><pubDate>Sun, 30 Jan 2011 14:12:03 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:15304</guid><dc:creator>simonsabin</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sqlblogcasts.com/blogs/simons/rsscomments.aspx?PostID=15304</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sqlblogcasts.com/blogs/simons/commentapi.aspx?PostID=15304</wfw:comment><comments>http://sqlblogcasts.com/blogs/simons/archive/2011/01/30/entity-framework-support-for-table-valued-functions-and-thus-full-text.aspx#comments</comments><description>One of my most popular posts with over 10, 000 hits is how to enable full text when using LINQ to SQL http://sqlblogcasts.com/blogs/simons/archive/2008/12/18/LINQ-to-SQL---Enabling-Fulltext-searching.aspx , core to this is the use of a table valued function...(&lt;a href="http://sqlblogcasts.com/blogs/simons/archive/2011/01/30/entity-framework-support-for-table-valued-functions-and-thus-full-text.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=15304" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Full+Text/default.aspx">Full Text</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/LINQ+To+SQL/default.aspx">LINQ To SQL</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Entity+framework/default.aspx">Entity framework</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/ORM/default.aspx">ORM</category></item><item><title>ORMs - Should DBAs just lighten up?</title><link>http://sqlblogcasts.com/blogs/simons/archive/2010/03/12/ORMs---Should-DBAs-just-lighten-up-.aspx</link><pubDate>Fri, 12 Mar 2010 23:27:12 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:13269</guid><dc:creator>simonsabin</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sqlblogcasts.com/blogs/simons/rsscomments.aspx?PostID=13269</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sqlblogcasts.com/blogs/simons/commentapi.aspx?PostID=13269</wfw:comment><comments>http://sqlblogcasts.com/blogs/simons/archive/2010/03/12/ORMs---Should-DBAs-just-lighten-up-.aspx#comments</comments><description>
&lt;p&gt;I did a presentation at &lt;a href="http://developerdeveloperdeveloper.com/ddd8/"&gt;&lt;font color="#b2265d"&gt;DDD8&lt;/font&gt;&lt;/a&gt; on the entity framework and how to stop your DBA 
from having a heart attack. You can find my demos and slide deck here &lt;a href="http://sqlblogcasts.com/blogs/simons/archive/2010/01/30/Entity-Framework-how-to-stop-your-DBA-having-a-heart-attack.aspx"&gt;http://sqlblogcasts.com/blogs/simons/archive/2010/01/30/Entity-Framework-how-to-stop-your-DBA-having-a-heart-attack.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Whilst at DDD &lt;a&gt;Mike Ormond&lt;/a&gt; 
interviewed me about my view on ORMs and the battel between DBAs and Devs. To 
see what I said&amp;nbsp;go to&lt;a href="http://bit.ly/bnf1By"&gt;http://bit.ly/bnf1By&lt;/a&gt;&lt;/p&gt;&lt;hr /&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt; 
&lt;/script&gt;
&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=13269" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Performance/default.aspx">Performance</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Entity+framework/default.aspx">Entity framework</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/ORM/default.aspx">ORM</category></item><item><title>DDD 8 Entity framework follow up - Will cast(column as int) allow use of an index</title><link>http://sqlblogcasts.com/blogs/simons/archive/2010/01/31/DDD-8-Entity-framework-follow-up---Will-cast-column-as-int--allow-use-of-an-index.aspx</link><pubDate>Sun, 31 Jan 2010 18:53:42 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:12958</guid><dc:creator>simonsabin</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sqlblogcasts.com/blogs/simons/rsscomments.aspx?PostID=12958</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sqlblogcasts.com/blogs/simons/commentapi.aspx?PostID=12958</wfw:comment><comments>http://sqlblogcasts.com/blogs/simons/archive/2010/01/31/DDD-8-Entity-framework-follow-up---Will-cast-column-as-int--allow-use-of-an-index.aspx#comments</comments><description>
&lt;p&gt;I pointed out yesterday that the EntityFramework doesn&amp;#39;t 
like smallints. Well it does and it doesn&amp;#39;t The model handles them fine and the 
objects have datatypes of int16 which is great.&lt;/p&gt;
&lt;p&gt;However the queries that are generated do this odd thing with any predicates 
on such columns. It applies a cast to column.i.e&lt;/p&gt;
&lt;p style="MARGIN:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;span style="LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:14pt;mso-no-proof:yes;"&gt;where&lt;/span&gt;&lt;span style="LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:14pt;mso-no-proof:yes;"&gt; 
&lt;span style="COLOR:fuchsia;"&gt;cast&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;(&lt;/span&gt;col2 
&lt;span style="COLOR:blue;"&gt;as&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;&lt;span style="COLOR:gray;"&gt;)=&lt;/span&gt; @d&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;At first glance I thought oh now not another screw up with the SQL from 
Entity framework, but on inspection of a query plan where the column in question 
was indexed I still got a seek operation. Very nice, well done optimisation 
team.&lt;/p&gt;
&lt;p&gt;When I pointed this out, I was asked whether this worked on SQL2005. Having 
only got a SQL2008 instance on my laptop I took the question away for testing. 
The reason of the question could be related to the fact that in SQL 2008 the 
introduced the ability to cast a datetime to a date to be able to look for 
specific days of data and still use an index.&lt;/p&gt;
&lt;p&gt;I have now tested and can state that it does work on SQL 
2005.&lt;/p&gt;
&lt;hr /&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt; 
&lt;/script&gt;
&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12958" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Entity+framework/default.aspx">Entity framework</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/DDD/default.aspx">DDD</category></item><item><title>Entity Framework how to stop your DBA having a heart attack</title><link>http://sqlblogcasts.com/blogs/simons/archive/2010/01/30/Entity-Framework-how-to-stop-your-DBA-having-a-heart-attack.aspx</link><pubDate>Sat, 30 Jan 2010 14:30:32 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:12954</guid><dc:creator>simonsabin</dc:creator><slash:comments>10</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sqlblogcasts.com/blogs/simons/rsscomments.aspx?PostID=12954</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sqlblogcasts.com/blogs/simons/commentapi.aspx?PostID=12954</wfw:comment><comments>http://sqlblogcasts.com/blogs/simons/archive/2010/01/30/Entity-Framework-how-to-stop-your-DBA-having-a-heart-attack.aspx#comments</comments><description>
&lt;p&gt;My code and presentation from my session at Developer 
Day 8 are now available here&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sqlknowhow.com/presentations/ddd_8/DDD_8-Entity_Framework.zip"&gt; DDD_8-Entity_Framework Code&lt;/a&gt; &lt;br /&gt;
&lt;a href="http://www.sqlknowhow.com/presentations/ddd_8/Entity_Framework.pptx"&gt;Entity framework presentation &lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;Any questions let me know.&lt;/p&gt;
&lt;p&gt;Also for more on the new features in Entity Framework v next go to &lt;a href="http://blogs.msdn.com/adonet/archive/2009/08/05/improvements-to-the-generated-sql-in-net-4-0-beta1.aspx"&gt;http://blogs.msdn.com/adonet/archive/2009/08/05/improvements-to-the-generated-sql-in-net-4-0-beta1.aspx&lt;/a&gt;&lt;/p&gt;&lt;hr /&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt; 
&lt;/script&gt;
&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12954" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Performance/default.aspx">Performance</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Community/default.aspx">Community</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Speaking/default.aspx">Speaking</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Entity+framework/default.aspx">Entity framework</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Query+Tuning/default.aspx">Query Tuning</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/DDD/default.aspx">DDD</category></item><item><title>Entity Framework - MergeOption.NoTracking and CompiledQuery.Compile</title><link>http://sqlblogcasts.com/blogs/simons/archive/2010/01/02/Entity-Framework---MergeOption-NoTracking-and-CompiledQuery-Compile.aspx</link><pubDate>Sat, 02 Jan 2010 15:52:20 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:12767</guid><dc:creator>simonsabin</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sqlblogcasts.com/blogs/simons/rsscomments.aspx?PostID=12767</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sqlblogcasts.com/blogs/simons/commentapi.aspx?PostID=12767</wfw:comment><comments>http://sqlblogcasts.com/blogs/simons/archive/2010/01/02/Entity-Framework---MergeOption-NoTracking-and-CompiledQuery-Compile.aspx#comments</comments><description>
&lt;p&gt;Two things that people tell you about Entity framework 
performance are, use the Compiled Queryies&amp;nbsp;and potentially remove tracking 
when its not needed. You can achieve this by using the CompiledQuery.Compile 
function to obtain a function that is your compiled query and to set the 
MergeOption of the relevant entities on the ObjectContext.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve just finished banging my head against a wall when trying to assess the 
performance of these together. &lt;/p&gt;
&lt;p&gt;This was my simple code. Create a static readonly function that is the 
compiled query and then in by test function checking the status of a check box 
to set the MergeOption to MergeOption.NoTracking.&lt;/p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;"&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;"&gt;static&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;"&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;readonly&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:#2b91af;"&gt;Func&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;&lt;/font&gt;&lt;span style="COLOR:#2b91af;"&gt;MobileMinderEntities&lt;/span&gt;&lt;font color="#000000"&gt;, 
&lt;/font&gt;&lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;&lt;font color="#000000"&gt;, &lt;/font&gt;&lt;span style="COLOR:#2b91af;"&gt;IQueryable&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;&lt;/font&gt;&lt;span style="COLOR:#2b91af;"&gt;Job&lt;/span&gt;&lt;font color="#000000"&gt;&amp;gt;&amp;gt; 
JobSelect&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/span&gt;= &lt;/font&gt;&lt;span style="COLOR:#2b91af;"&gt;CompiledQuery&lt;/span&gt;&lt;font color="#000000"&gt;.Compile&amp;lt;&lt;/font&gt;&lt;span style="COLOR:#2b91af;"&gt;MobileMinderEntities&lt;/span&gt;&lt;font color="#000000"&gt;, 
&lt;/font&gt;&lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;&lt;font color="#000000"&gt;, &lt;/font&gt;&lt;span style="COLOR:#2b91af;"&gt;IQueryable&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;&lt;/font&gt;&lt;span style="COLOR:#2b91af;"&gt;Job&lt;/span&gt;&lt;font color="#000000"&gt;&amp;gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;((ctx, 
jobid) =&amp;gt; &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;from&lt;/span&gt;&lt;font color="#000000"&gt; j 
&lt;/font&gt;&lt;span style="COLOR:blue;"&gt;in&lt;/span&gt;&lt;font color="#000000"&gt; 
ctx.Job&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;where&lt;/span&gt;&lt;font color="#000000"&gt; 
j.Person.PersonId == jobid&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;&amp;amp;&amp;amp; ctx.JobCompleted.Any(c =&amp;gt; c.Signature == &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;null&lt;/span&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;span style="LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;select&lt;/span&gt;&lt;font color="#000000"&gt; 
j);&lt;/font&gt;&lt;/span&gt;&lt;span style="LINE-HEIGHT:115%;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;private&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;void&lt;/span&gt;&lt;font color="#000000"&gt; 
btnTest_Click(&lt;/font&gt;&lt;span style="COLOR:blue;"&gt;object&lt;/span&gt;&lt;font color="#000000"&gt; 
sender, &lt;/font&gt;&lt;span style="COLOR:#2b91af;"&gt;EventArgs&lt;/span&gt;&lt;font color="#000000"&gt; 
e)&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/span&gt;{&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;int&lt;/span&gt;&lt;font color="#000000"&gt; var = 
1;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;using&lt;/span&gt;&lt;font color="#000000"&gt; 
(&lt;/font&gt;&lt;span style="COLOR:#2b91af;"&gt;MobileMinderEntities&lt;/span&gt;&lt;font color="#000000"&gt; me = &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;new&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR:#2b91af;"&gt;MobileMinderEntities&lt;/span&gt;&lt;font color="#000000"&gt;())&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/span&gt;{&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;if&lt;/span&gt;&lt;font color="#000000"&gt; 
(!chkTrack.Checked)&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/span&gt;{&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/span&gt;me.Job.MergeOption = &lt;/font&gt;&lt;span style="COLOR:#2b91af;"&gt;MergeOption&lt;/span&gt;&lt;font color="#000000"&gt;.NoTracking;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/span&gt;}&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;COLOR:blue;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;var 
l = JobSelect2(me, var);&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/span&gt;OutputTraceQuery(l);&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;var&lt;/span&gt;&lt;font color="#000000"&gt; l_l = 
l.ToList();&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/span&gt;}&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0cm 0cm 10pt;" class="MsoNormal"&gt;&lt;span style="LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;mso-no-proof:yes;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/span&gt;}&lt;/font&gt;&lt;/span&gt;&lt;span style="LINE-HEIGHT:115%;FONT-SIZE:9pt;mso-bidi-font-size:11.0pt;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="LINE-HEIGHT:normal;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I couldn&amp;#39;t figure out why I wasn&amp;#39;t getting much difference, so I started 
profiling the code to see what was going on. Not much there (but I&amp;#39;m not a 
profiling expert). I then started hacking code to debug what was going on, what 
I couldn&amp;#39;t figure was that when I turned tracking on, my object context was 
reporting no tracked objects. Uhh. &lt;/p&gt;
&lt;p&gt;Can you spot whats wrong?&lt;/p&gt;
&lt;p&gt;
&lt;p&gt;After making a small dent in the wall I figured the only way that this was 
happening was if the traking was being cached. Initially I thought it was the 
object context but then thought that its disposed every time, its not a 
singleton. So then looked at the function, ok so this is a static readonly, so 
only one but surely only the execution tree is cached.&lt;/p&gt;
&lt;p&gt;Well it appears not. It appears that the compiled query also includes the 
tracking options.&lt;/p&gt;
&lt;p&gt;That sort of put my test in a difficult position.The solution I came up with 
was to use two functions one that would only be used for tracking and one for 
non tracked execution. This worked a treat.&lt;/p&gt;
&lt;p&gt;So a word to the wise if you are using CompiledQueries or ObjectQuery.Compile 
be careful if you are setting the mergeoption on your 
ObjectContext&lt;/p&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt; 
&lt;/script&gt;
&lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=12767" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Performance/default.aspx">Performance</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Entity+framework/default.aspx">Entity framework</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Query+Tuning/default.aspx">Query Tuning</category></item><item><title>Whats the score with LINQ to SQL?</title><link>http://sqlblogcasts.com/blogs/simons/archive/2008/11/16/Whats-the-score-with-LINQ-to-SQL-.aspx</link><pubDate>Sun, 16 Nov 2008 00:16:48 GMT</pubDate><guid isPermaLink="false">fa8c4e8e-46a3-4193-8264-2c1a9cb3475d:11027</guid><dc:creator>simonsabin</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sqlblogcasts.com/blogs/simons/rsscomments.aspx?PostID=11027</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://sqlblogcasts.com/blogs/simons/commentapi.aspx?PostID=11027</wfw:comment><comments>http://sqlblogcasts.com/blogs/simons/archive/2008/11/16/Whats-the-score-with-LINQ-to-SQL-.aspx#comments</comments><description>
&lt;p&gt;LINQ to SQL (and any ORM for that matter) has the marmite factor. You either 
love it or hate it. Whats more many of those that hate it haven&amp;#39;t tried it. In 
many cases the hate it crowd are making a decision based on previous experience 
with systems using ORM solutions.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve been looking at and trying to use LINQ to SQL for a while and thought I 
would post my findings thoughts. Before starting this series of posts I thought 
I would see what others have said. I had heard something about an announcement 
about LINQ to SQL and LINQ to Entities and found the post hear. &lt;a href="http://blogs.msdn.com/adonet/archive/2008/10/31/clarifying-the-message-on-l2s-futures.aspx"&gt;http://blogs.msdn.com/adonet/archive/2008/10/31/clarifying-the-message-on-l2s-futures.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I made a conscious decision to look at L2S rather that L2E for these 
reasons,&lt;/p&gt;
&lt;p style="MARGIN-LEFT:36pt;TEXT-INDENT:-18pt;mso-list:l0 level1 lfo1;"&gt;&lt;span style="mso-list:Ignore;"&gt;1.&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/span&gt;&lt;/span&gt;Its simpler&lt;/p&gt;
&lt;p style="MARGIN-LEFT:36pt;TEXT-INDENT:-18pt;mso-list:l0 level1 lfo1;"&gt;&lt;span style="mso-list:Ignore;"&gt;2.&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/span&gt;&lt;/span&gt;It allows separation of code and database mapping easily. This is 
commonly referred to as POCO&lt;/p&gt;
&lt;p style="MARGIN-LEFT:36pt;TEXT-INDENT:-18pt;mso-list:l0 level1 lfo1;"&gt;&lt;span style="mso-list:Ignore;"&gt;3.&lt;span style="FONT:7pt &amp;#39;Times New Roman&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/span&gt;&lt;/span&gt;It supports more SQL features&lt;/p&gt;
&lt;p&gt;However it seems that L2E will be enhanced to include the L2S features that 
are missing.&lt;/p&gt;
&lt;p&gt;Thats a real shame and the biggest reason for me is the number of levels of 
interpretation.&lt;/p&gt;
&lt;p&gt;When you right a LINQ query with L2S your LINQ query is translated to an 
expression tree and then translated to SQL.&lt;/p&gt;
&lt;p&gt;With L2E you have an extra step because the entity framework is a framework 
that sits on stop of any provider (that has been written). To enable that it has 
its own data access language Entity SQL. So to get to SQL, your LINQ query is 
translated from LINQ to ESQL to SQL.&lt;/p&gt;
&lt;p&gt;Anyone thats worked or seen translated text will know that often what you put 
in is often not what you get out. There is a common games on radio in the UK 
where they translate an album/track name to a language and then back to English. 
The quiz is then to guess what the original album/track name was given the final 
translated text. (A bit like Chinese whispers).&lt;/p&gt;
&lt;p&gt;We all know how complex SQL is, so you can understand why generally the SQL 
you get from L2E is more complex than with L2S. &lt;/p&gt;
&lt;p&gt;I personally like to keep things simple and so I’m disappointed by the 
decision to concentrate. Although all is not lost. &lt;/p&gt;
&lt;p&gt;If you use standard practice of implementing a data layer then you could move 
to L2E in the future. Whats more your SELECT LINQ queries against a set of L2E 
objects should be similar to those for L2S. The main difference is when you want 
to do your insert, update and delete operations, the two technologies use 
different mechanisms. Further more you will likely have to change you validation 
code to use the different technology, although the core rules code shouldn’t 
have to change.&lt;/p&gt;
&lt;p&gt;I would still stick with L2S until the next version of EF. I&amp;#39;ll discuss some 
of my findings in future posts.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;
&lt;script type="text/javascript" src="http://sqlblogcasts.com/sitefiles/1000/Social_Buttons.js"&gt;&lt;/script&gt;
&lt;hr /&gt;
-
&lt;script type="text/javascript" src="http://sqlblogcasts.com/sitefiles/1000/google_rss.js"&gt;
&lt;/script&gt;
&lt;script type="text/javascript"&gt;var height=90;var width=720;&lt;/script&gt;
&lt;script src="http://www.sqlknowhow.com/scripts/Banner.js" type="text/javascript"&gt;
&lt;/script&gt;
 &lt;img src="http://sqlblogcasts.com/aggbug.aspx?PostID=11027" width="1" height="1"&gt;</description><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/LINQ+To+SQL/default.aspx">LINQ To SQL</category><category domain="http://sqlblogcasts.com/blogs/simons/archive/tags/Entity+framework/default.aspx">Entity framework</category></item></channel></rss>