<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jigsaw Boys &#187; linq</title>
	<atom:link href="http://www.jigsawboys.com/tag/linq/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jigsawboys.com</link>
	<description>Security, Network and Computer Tech Tip Database!</description>
	<lastBuildDate>Tue, 07 Sep 2010 02:43:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to fetch Last Record in Subsonic</title>
		<link>http://www.jigsawboys.com/2009/12/22/how-to-fetch-last-record-in-subsonic/</link>
		<comments>http://www.jigsawboys.com/2009/12/22/how-to-fetch-last-record-in-subsonic/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 06:18:22 +0000</pubDate>
		<dc:creator>Jamsi</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[subsonic]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.jigsawboys.com/?p=291</guid>
		<description><![CDATA[Is it just me or is Subsonic the topic of discussion right now? I had a need to retrieve the last ID that had been generated in a table; that being, the last &#8220;auto increment&#8221; ID of a table. The following example worked a charm using Subsonic and activerecord. var fetch_ref_id = contract.All().OrderByDescending(c =&#62; c.id).Take(1).ToList(); [...]


Related posts:<ol><li><a href='http://www.jigsawboys.com/2009/12/22/subsonic-ordering-orderbydescending/' rel='bookmark' title='Permanent Link: Subsonic ordering &#8211; OrderByDescending'>Subsonic ordering &#8211; OrderByDescending</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Is it just me or is Subsonic the topic of discussion right now? <img src='http://www.jigsawboys.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
I had a need to retrieve the last ID that had been generated in a table; that being, the last &#8220;auto increment&#8221; ID of a table.</p>
<p>The following example worked a charm using Subsonic and activerecord.</p>
<pre class="brush: csharp;">
var fetch_ref_id = contract.All().OrderByDescending(c =&gt; c.id).Take(1).ToList();
if (iRef_new_id != null)
{
     iRef_new_id = fetch_ref_id[0].id;
}
</pre>
<p>As you can see, it creates a new list (noted by the ToList()) by connecting to the table &#8220;category&#8221;, it then selects all results (All()) and then orders the list by Descending and finally, the take(1) simply takes the top record.</p>
<p>I then whack the result (if you have a column called id) into a integer.</p>


<p>Related posts:<ol><li><a href='http://www.jigsawboys.com/2009/12/22/subsonic-ordering-orderbydescending/' rel='bookmark' title='Permanent Link: Subsonic ordering &#8211; OrderByDescending'>Subsonic ordering &#8211; OrderByDescending</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jigsawboys.com/2009/12/22/how-to-fetch-last-record-in-subsonic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subsonic ordering &#8211; OrderByDescending</title>
		<link>http://www.jigsawboys.com/2009/12/22/subsonic-ordering-orderbydescending/</link>
		<comments>http://www.jigsawboys.com/2009/12/22/subsonic-ordering-orderbydescending/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 05:41:22 +0000</pubDate>
		<dc:creator>Jamsi</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[subsonic]]></category>

		<guid isPermaLink="false">http://www.jigsawboys.com/?p=288</guid>
		<description><![CDATA[So the subsonic documentation sucks. If you&#8217;re new to activerecord, linq and subsonic in general; you&#8217;ll find it fairly hard to construct basic queries. However once you&#8217;ve got it under control, it&#8217;s a piece of cake. To sort your table using activerecord, use the following examples; To sort ascending by a column called name var [...]


Related posts:<ol><li><a href='http://www.jigsawboys.com/2009/12/22/how-to-fetch-last-record-in-subsonic/' rel='bookmark' title='Permanent Link: How to fetch Last Record in Subsonic'>How to fetch Last Record in Subsonic</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>So the subsonic documentation sucks. If you&#8217;re new to activerecord, linq and subsonic in general; you&#8217;ll find it fairly hard to construct basic queries. However once you&#8217;ve got it under control, it&#8217;s a piece of cake.</p>
<p>To sort your table using activerecord, use the following examples;</p>
<p><b>To sort ascending by a column called name</b></p>
<pre class="brush: csharp;">
var categories = category.All().OrderBy(c =&gt; c.name);
</pre>
<p><b>To sort descendingby a column called name</b></p>
<pre class="brush: csharp;">
var categories = category.All().OrderByDescending(c =&gt; c.name);
</pre>
<p>You can then just bind to your gridview/dropdown list or whatever you like.</p>
<pre class="brush: csharp;">
            if (categories != null)
            {
                drp.DataSource = categories ;
                drp.DataBind();
            }
</pre>


<p>Related posts:<ol><li><a href='http://www.jigsawboys.com/2009/12/22/how-to-fetch-last-record-in-subsonic/' rel='bookmark' title='Permanent Link: How to fetch Last Record in Subsonic'>How to fetch Last Record in Subsonic</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jigsawboys.com/2009/12/22/subsonic-ordering-orderbydescending/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
