<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" version="2.0">
  <channel>
    <title>DotNetDoc - LINQ</title>
    <link>http://www.dotnetdoc.com/</link>
    <description>My Ramblings on .Net and other stuff</description>
    <language>en-us</language>
    <copyright>Daniel Egan</copyright>
    <lastBuildDate>Wed, 12 Nov 2008 18:29:24 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.9.6264.0</generator>
    <managingEditor>degan@ocgpros.com</managingEditor>
    <webMaster>degan@ocgpros.com</webMaster>
    <item>
      <trackback:ping>http://www.dotnetdoc.com/Trackback.aspx?guid=fddc8d19-8bf5-4622-8998-5878e9c585c9</trackback:ping>
      <pingback:server>http://www.dotnetdoc.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnetdoc.com/PermaLink,guid,fddc8d19-8bf5-4622-8998-5878e9c585c9.aspx</pingback:target>
      <dc:creator>Daniel Egan</dc:creator>
      <wfw:comment>http://www.dotnetdoc.com/CommentView,guid,fddc8d19-8bf5-4622-8998-5878e9c585c9.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnetdoc.com/SyndicationService.asmx/GetEntryCommentsRss?guid=fddc8d19-8bf5-4622-8998-5878e9c585c9</wfw:commentRss>
      <title>TechDays08 Day 2 Talk - VSTO App with LINQ</title>
      <guid isPermaLink="false">http://www.dotnetdoc.com/PermaLink,guid,fddc8d19-8bf5-4622-8998-5878e9c585c9.aspx</guid>
      <link>http://www.dotnetdoc.com/PermaLink,guid,fddc8d19-8bf5-4622-8998-5878e9c585c9.aspx</link>
      <pubDate>Wed, 12 Nov 2008 18:29:24 GMT</pubDate>
      <description>&lt;p&gt;
Here are my slides for my talk at the TechDays08 in Costa Mesa on November 12th 2008.
Yesterday was a fun day and we used Twitter, Facebook, Email to keep comments and
questions commig all day long (durring the sessions). We will be doing this today
to.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;div id=__ss_746380 style="WIDTH: 425px; TEXT-ALIGN: left"&gt;&lt;a title="Daniel Egan Msdn Tech Days Oc Day2" style="DISPLAY: block; MARGIN: 12px 0px 3px; FONT: 14px Helvetica,Arial,Sans-serif; TEXT-DECORATION: underline" href="http://www.slideshare.net/DanielEgan/daniel-egan-msdn-tech-days-oc-day2-presentation?type=powerpoint"&gt;Daniel
Egan Msdn Tech Days Oc Day2&lt;/a&gt; 
&lt;object style="MARGIN: 0px" height=355 width=425&gt;
&lt;param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=danieleganmsdntechdaysocday2-1226514059537904-8&amp;amp;stripped_title=daniel-egan-msdn-tech-days-oc-day2-presentation"&gt;
&lt;param name="allowFullScreen" value="true"&gt;
&lt;param name="allowScriptAccess" value="always"&gt;
&lt;embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=danieleganmsdntechdaysocday2-1226514059537904-8&amp;stripped_title=daniel-egan-msdn-tech-days-oc-day2-presentation" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"&gt;&lt;/embed&gt;
&lt;/object&gt;
&lt;div style="FONT-SIZE: 11px; PADDING-TOP: 2px; FONT-FAMILY: tahoma,arial; HEIGHT: 26px"&gt;View
SlideShare &lt;a title="View Daniel Egan Msdn Tech Days Oc Day2 on SlideShare" style="TEXT-DECORATION: underline" href="http://www.slideshare.net/DanielEgan/daniel-egan-msdn-tech-days-oc-day2-presentation?type=powerpoint"&gt;presentation&lt;/a&gt; or &lt;a style="TEXT-DECORATION: underline" href="http://www.slideshare.net/upload?type=powerpoint"&gt;Upload&lt;/a&gt; your
own.
&lt;/div&gt;
&lt;/div&gt;
Enjoy... DotNetDoc - Daniel Egan&lt;img width="0" height="0" src="http://www.dotnetdoc.com/aggbug.ashx?id=fddc8d19-8bf5-4622-8998-5878e9c585c9" /&gt;</description>
      <comments>http://www.dotnetdoc.com/CommentView,guid,fddc8d19-8bf5-4622-8998-5878e9c585c9.aspx</comments>
      <category>Events;LINQ;Speaking Events</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnetdoc.com/Trackback.aspx?guid=f6cd03c5-6757-4419-9286-c5db260bd82a</trackback:ping>
      <pingback:server>http://www.dotnetdoc.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnetdoc.com/PermaLink,guid,f6cd03c5-6757-4419-9286-c5db260bd82a.aspx</pingback:target>
      <dc:creator>Daniel Egan</dc:creator>
      <wfw:comment>http://www.dotnetdoc.com/CommentView,guid,f6cd03c5-6757-4419-9286-c5db260bd82a.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnetdoc.com/SyndicationService.asmx/GetEntryCommentsRss?guid=f6cd03c5-6757-4419-9286-c5db260bd82a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
 
</p>
        <p>
If you are looking for good overview of LINQ and how to implement it in an ASP.Net
application you can check out my LINQ presentation which was recorded at a User Group
meeting in Florida. Follow the Link (pun intended) below to watch the video on INETA
LIVE. A new interactive companion website to the new main INETA website. 
</p>
        <p>
          <a href="http://live.ineta.org/Videos/Player.aspx?video=137bddf7-6fcc-4408-b6f2-1a3f0b2d4560">
            <img alt="" src="http://www.DotNetDoc.com/content/binary/041208_2107_LINQtotheEn1.png" border="0" />
          </a>
        </p>
        <p>
 
</p>
        <p>
Enjoy. 
</p>
        <p>
Doc (Daniel N. Egan)
</p>
        <img width="0" height="0" src="http://www.dotnetdoc.com/aggbug.ashx?id=f6cd03c5-6757-4419-9286-c5db260bd82a" />
      </body>
      <title>LINQ to the Enterprise - Video on INETA LIVE</title>
      <guid isPermaLink="false">http://www.dotnetdoc.com/PermaLink,guid,f6cd03c5-6757-4419-9286-c5db260bd82a.aspx</guid>
      <link>http://www.dotnetdoc.com/PermaLink,guid,f6cd03c5-6757-4419-9286-c5db260bd82a.aspx</link>
      <pubDate>Sat, 12 Apr 2008 21:08:02 GMT</pubDate>
      <description>&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
If you are looking for good overview of LINQ and how to implement it in an ASP.Net
application you can check out my LINQ presentation which was recorded at a User Group
meeting in Florida. Follow the Link (pun intended) below to watch the video on INETA
LIVE. A new interactive companion website to the new main INETA website. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://live.ineta.org/Videos/Player.aspx?video=137bddf7-6fcc-4408-b6f2-1a3f0b2d4560"&gt;&lt;img alt="" src="http://www.DotNetDoc.com/content/binary/041208_2107_LINQtotheEn1.png" border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Enjoy. 
&lt;/p&gt;
&lt;p&gt;
Doc (Daniel N. Egan)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnetdoc.com/aggbug.ashx?id=f6cd03c5-6757-4419-9286-c5db260bd82a" /&gt;</description>
      <comments>http://www.dotnetdoc.com/CommentView,guid,f6cd03c5-6757-4419-9286-c5db260bd82a.aspx</comments>
      <category>LINQ</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnetdoc.com/Trackback.aspx?guid=1e20a926-7225-466c-a4f8-15e8ec8e7cbe</trackback:ping>
      <pingback:server>http://www.dotnetdoc.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnetdoc.com/PermaLink,guid,1e20a926-7225-466c-a4f8-15e8ec8e7cbe.aspx</pingback:target>
      <dc:creator>Daniel Egan</dc:creator>
      <wfw:comment>http://www.dotnetdoc.com/CommentView,guid,1e20a926-7225-466c-a4f8-15e8ec8e7cbe.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnetdoc.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1e20a926-7225-466c-a4f8-15e8ec8e7cbe</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
At my last talk I had the following question. 
</p>
        <blockquote>
          <p>
"When returning a LINQ entity using the .Single() extension, what would happen if
the result returned more than one row?" 
</p>
        </blockquote>
        <p>
The simple answer of course was that it would throw an exception, but I told him I
would elaborate in a blog post. So here it is. Most LINQ queries will return an IEnumerable
collection of objects as the result of your LINQ query. In order to only return a
single entity, you have a couple of options. 
</p>
        <p>
        </p>
        <p>
          <span style="font-size:14pt">
            <strong>Single</strong>
          </span>– Will return back a single
entity<br /><span style="font-size:14pt"><strong>SingleOrDefault</strong></span>– Will return
back a single entity or a Default if nothing is found 
</p>
        <p>
Both of these will throw an <strong><em>InvalidOperationException</em></strong> if
the query returns more than one row. 
</p>
        <p>
          <img src="http://www.DotNetDoc.com/content/binary/032308_0657_LINQQuestio1.png" alt="" />
        </p>
        <p>
If you know that your query may return more than one record, you can use the following
Extension methods to return a single entity from a collection of entities. (or the
OrDefault versions) 
</p>
        <p>
          <span style="font-size:14pt">
            <strong>ElementAt</strong>
          </span>- return the entity
at the given index 
</p>
        <p>
          <img src="http://www.DotNetDoc.com/content/binary/032308_0657_LINQQuestio2.png" alt="" />
        </p>
        <p>
          <span style="font-size:14pt">
            <strong>First</strong>
          </span>- Returns the first entity
of the collection 
</p>
        <p>
          <img src="http://www.DotNetDoc.com/content/binary/032308_0657_LINQQuestio3.png" alt="" />
        </p>
        <p>
          <span style="font-size:14pt">
            <strong>Last</strong>
          </span>– Returns the last entity
in the collection. 
</p>
        <p>
          <img src="http://www.DotNetDoc.com/content/binary/032308_0657_LINQQuestio4.png" alt="" />
        </p>
        <p>
Finally, you can also pass a predicate (a condition) as a parameter. 
</p>
        <p>
          <img src="http://www.DotNetDoc.com/content/binary/032308_0657_LINQQuestio5.png" alt="" />
        </p>
        <p>
Here we are looking for the first publisher in the pubisher collecdtion that has a
country of USA. 
</p>
        <p>
        </p>
        <p>
Hope that helps. 
</p>
        <p>
Happy Programming 
</p>
        <p>
Doc 
</p>
        <p>
          <br />
        </p>
        <img width="0" height="0" src="http://www.dotnetdoc.com/aggbug.ashx?id=1e20a926-7225-466c-a4f8-15e8ec8e7cbe" />
      </body>
      <title>LINQ Questions - .Single()</title>
      <guid isPermaLink="false">http://www.dotnetdoc.com/PermaLink,guid,1e20a926-7225-466c-a4f8-15e8ec8e7cbe.aspx</guid>
      <link>http://www.dotnetdoc.com/PermaLink,guid,1e20a926-7225-466c-a4f8-15e8ec8e7cbe.aspx</link>
      <pubDate>Sun, 23 Mar 2008 06:57:52 GMT</pubDate>
      <description>&lt;p&gt;
At my last talk I had the following question. 
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;
"When returning a LINQ entity using the .Single() extension, what would happen if
the result returned more than one row?" 
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
The simple answer of course was that it would throw an exception, but I told him I
would elaborate in a blog post. So here it is. Most LINQ queries will return an IEnumerable
collection of objects as the result of your LINQ query. In order to only return a
single entity, you have a couple of options. 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-size:14pt"&gt;&lt;strong&gt;Single&lt;/strong&gt; &lt;/span&gt;– Will return back a single
entity&lt;br /&gt;
&lt;span style="font-size:14pt"&gt;&lt;strong&gt;SingleOrDefault&lt;/strong&gt; &lt;/span&gt;– Will return
back a single entity or a Default if nothing is found 
&lt;/p&gt;
&lt;p&gt;
Both of these will throw an &lt;strong&gt;&lt;em&gt;InvalidOperationException&lt;/em&gt;&lt;/strong&gt; if
the query returns more than one row. 
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.DotNetDoc.com/content/binary/032308_0657_LINQQuestio1.png" alt="" /&gt; 
&lt;/p&gt;
&lt;p&gt;
If you know that your query may return more than one record, you can use the following
Extension methods to return a single entity from a collection of entities. (or the
OrDefault versions) 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-size:14pt"&gt;&lt;strong&gt;ElementAt&lt;/strong&gt; &lt;/span&gt;- return the entity
at the given index 
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.DotNetDoc.com/content/binary/032308_0657_LINQQuestio2.png" alt="" /&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-size:14pt"&gt;&lt;strong&gt;First&lt;/strong&gt; &lt;/span&gt;- Returns the first entity
of the collection 
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.DotNetDoc.com/content/binary/032308_0657_LINQQuestio3.png" alt="" /&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="font-size:14pt"&gt;&lt;strong&gt;Last&lt;/strong&gt; &lt;/span&gt;– Returns the last entity
in the collection. 
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.DotNetDoc.com/content/binary/032308_0657_LINQQuestio4.png" alt="" /&gt; 
&lt;/p&gt;
&lt;p&gt;
Finally, you can also pass a predicate (a condition) as a parameter. 
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.DotNetDoc.com/content/binary/032308_0657_LINQQuestio5.png" alt="" /&gt; 
&lt;/p&gt;
&lt;p&gt;
Here we are looking for the first publisher in the pubisher collecdtion that has a
country of USA. 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Hope that helps. 
&lt;/p&gt;
&lt;p&gt;
Happy Programming 
&lt;/p&gt;
&lt;p&gt;
Doc 
&lt;/p&gt;
&lt;p&gt;
&lt;br /&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnetdoc.com/aggbug.ashx?id=1e20a926-7225-466c-a4f8-15e8ec8e7cbe" /&gt;</description>
      <comments>http://www.dotnetdoc.com/CommentView,guid,1e20a926-7225-466c-a4f8-15e8ec8e7cbe.aspx</comments>
      <category>LINQ</category>
    </item>
  </channel>
</rss>