<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.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>Data Access and ObjectDataSource Control</title><link>http://forums.asp.net/23.aspx</link><description>Questions and discussions related to using ADO.NET for data access, and the ObjectDataSource control. &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=9&amp;c=17" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: return value from LINQ query</title><link>http://forums.asp.net/thread/3275019.aspx</link><pubDate>Sun, 05 Jul 2009 00:22:20 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275019</guid><dc:creator>bhadelia.imran</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275019.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=23&amp;PostID=3275019</wfw:commentRss><description>&lt;ol style="list-style-type:decimal;list-style-position:initial;list-style-image:initial;background-color:#ffffff;color:#5c5c5c;padding:0px;border:initial none initial;" start="1"&gt;
&lt;li style="font-size:11px;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:solid;border-width:initial;border-color:initial;list-style-type:decimal-leading-zero;list-style-image:initial;border-left-width:3px;border-left-color:#6ce26c;background-color:#ffffff;color:inherit;line-height:14px;"&gt;&lt;span style="color:black;background-color:inherit;padding:0px;margin:0px;border:initial none initial;"&gt;(From&amp;nbsp;r&amp;nbsp;&lt;span style="color:#006699;background-color:inherit;font-weight:bold;padding:0px;margin:0px;border:initial none initial;"&gt;In&lt;/span&gt;&lt;span style="color:black;background-color:inherit;padding:0px;margin:0px;border:initial none initial;"&gt;&amp;nbsp;dc.tblReunion_Infos&amp;nbsp;_&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style="font-size:11px;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:solid;border-width:initial;border-color:initial;list-style-type:decimal-leading-zero;list-style-image:initial;border-left-width:3px;border-left-color:#6ce26c;background-color:#f8f8f8;color:#5c5c5c;line-height:14px;"&gt;&lt;span style="color:black;background-color:inherit;padding:0px;margin:0px;border:initial none initial;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Where&amp;nbsp;r.ReunionIndex&amp;nbsp;=&amp;nbsp;strQS&amp;nbsp;_&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li style="font-size:11px;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:solid;border-width:initial;border-color:initial;list-style-type:decimal-leading-zero;list-style-image:initial;border-left-width:3px;border-left-color:#6ce26c;background-color:#ffffff;color:inherit;line-height:14px;"&gt;&lt;span style="color:black;background-color:inherit;padding:0px;margin:0px;border:initial none initial;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#006699;background-color:inherit;font-weight:bold;padding:0px;margin:0px;border:initial none initial;"&gt;Select&lt;/span&gt;&lt;span style="color:black;background-color:inherit;padding:0px;margin:0px;border:initial none initial;"&gt;&amp;nbsp;r.ReunionYear,&amp;nbsp;r.ReunionIndex).FirstOrDefault()&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;There must be FirstOrDefault function, please check it again.&lt;/p&gt;&lt;p&gt;Without making call to any ToList, First, FirstOrDefault, query cant get execute, First of FirstOrDefault will returns the first element after executing your query.&lt;/p&gt;</description></item><item><title>Re: return value from LINQ query</title><link>http://forums.asp.net/thread/3274932.aspx</link><pubDate>Sat, 04 Jul 2009 19:46:42 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274932</guid><dc:creator>muybn</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274932.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=23&amp;PostID=3274932</wfw:commentRss><description>&lt;p&gt;Thanks for your efforts,&amp;nbsp;but it didn&amp;#39;t like the &amp;quot;FirstOrDefault&amp;quot; after the final parenthesis; the closest I could get was the following, which still returned the same error as listed in my first entry.&lt;/p&gt;&lt;pre class="vb.net" name="code"&gt;Dim strQS As String = Request.QueryString(&amp;quot;index&amp;quot;)
lbl = Util.FindChild(Page, &amp;quot;lblEntry&amp;quot;)
Dim dc As alumniDataContext = New alumniDataContext
Dim data As New tblReunion_Info &amp;#39;= New tblReunion_Info
data = (From r In dc.tblReunion_Infos _
   Where r.ReunionIndex = strQS _
   Select r.ReunionYear.FirstOrDefault, r.ReunionIndex)
lbl.Text = data.ReunionYear
&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: return value from LINQ query</title><link>http://forums.asp.net/thread/3274851.aspx</link><pubDate>Sat, 04 Jul 2009 17:18:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274851</guid><dc:creator>JMayo</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274851.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=23&amp;PostID=3274851</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Try this:&lt;/p&gt;&lt;pre class="vb.net" name="code"&gt;04.data = (From r In dc.tblReunion_Infos _   
05. Where r.ReunionIndex = Request.QueryString(&amp;quot;index&amp;quot;) _   
06. Select r.ReunionYear, r.ReunionIndex)&lt;strong&gt;.FirstOrDefault&lt;/strong&gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;Your query returns an IQueryable(Of Customer), which is a collection and you need to either iterate through it with a for/for each loop or use a query operator like FirstOrDefault to extract the one item you need.&lt;/p&gt;
&lt;p&gt;Joe&lt;/p&gt;</description></item><item><title>return value from LINQ query</title><link>http://forums.asp.net/thread/3274507.aspx</link><pubDate>Sat, 04 Jul 2009 09:22:46 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274507</guid><dc:creator>muybn</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274507.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=23&amp;PostID=3274507</wfw:commentRss><description>&lt;p&gt;I want to set a label&amp;#39;s text equal&amp;nbsp;to a value I return from a LINQ query, as follows:&lt;/p&gt;&lt;pre class="vb.net" name="code"&gt;        Dim dc As New alumniDataContext
        Dim data As tblReunion_Info
        lbl = Util.FindChild(Page, &amp;quot;lblEntry&amp;quot;)
        data = (From r In dc.tblReunion_Infos _
         Where r.ReunionIndex = Request.QueryString(&amp;quot;index&amp;quot;) _
         Select r.ReunionYear, r.ReunionIndex)
        lbl.Text = data.ReunionYear
&lt;/pre&gt;
&lt;p&gt;Following is the error I receive, which obviously means that I have to do some converting somewhere. Your help will be appreciated.&lt;/p&gt;
&lt;p&gt;Unable to cast object of type &amp;#39;System.Data.Linq.DataQuery`[System.String,System.Int32]&amp;#39; to type &amp;#39;tblReunion_Info&amp;#39;.&amp;quot;&lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>