<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Jenifertrinh&#039;s Blog</title>
	<atom:link href="http://jenifertrinh.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jenifertrinh.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Fri, 04 Dec 2009 13:20:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='jenifertrinh.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Jenifertrinh&#039;s Blog</title>
		<link>http://jenifertrinh.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://jenifertrinh.wordpress.com/osd.xml" title="Jenifertrinh&#039;s Blog" />
	<atom:link rel='hub' href='http://jenifertrinh.wordpress.com/?pushpress=hub'/>
		<item>
		<title>ABC</title>
		<link>http://jenifertrinh.wordpress.com/2009/12/04/abc/</link>
		<comments>http://jenifertrinh.wordpress.com/2009/12/04/abc/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 13:20:55 +0000</pubDate>
		<dc:creator>jenifertrinh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jenifertrinh.wordpress.com/2009/12/04/abc/</guid>
		<description><![CDATA[LINQ to Objects &#8211; 5 Minute Overview &#8211; Hooked on LINQ Hooked on LINQ &#8211; Developers&#8217; Wiki for .NET Language Integrated Query Quick Search Advanced Search &#187; Navigation Home Page Advanced Search Categories All Pages (141) Recent Changes Resource links LINQ Books 5 Minute Overviews LINQ to Objects LINQ to SQL LINQ to XML FAQ [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jenifertrinh.wordpress.com&amp;blog=9442160&amp;post=31&amp;subd=jenifertrinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>	LINQ to Objects &#8211; 5 Minute Overview &#8211; Hooked on LINQ</p>
<div>
</div>
<div id="HeaderDiv">
<table width="100%">
<tr>
<td width="175">
       <a href="http://www.hookedonlinq.com/MainPage.ashx"><img src="Themes/HookedOnLINQ/Images/logo_small.gif"></a>
    </td>
<td>
<h1>Hooked on LINQ &#8211; Developers&#8217; Wiki <br />for .NET Language Integrated Query</h1>
</td>
<td align="right">
<b>Quick Search</b></p>
<p><a class="internallink" href="Search.aspx?FullText=1" title="Advanced Search &raquo;">Advanced Search &raquo;</a>
    </td>
</tr>
</table></div>
<div id="ContainerDiv">
<div id="SidebarDiv">
<div id="SidebarHeaderDiv">
<p>                    <!-- Used for layout purposes only -->
                </div>
<div id="SidebarContentDiv">
<div style="float:right;"><a href="RSS.aspx" title="Update notifications for Hooked on LINQ (RSS 2.0)"><img src="Themes/HookedOnLINQ/Images/RSS_button.gif" alt="RSS" /></a></div>
<p><a id="Navigation_0"></a><br />
<h3 class="separator">Navigation</h3>
<p></p>
<ul>
<li><b><a class="pagelink" href="MainPage.ashx" title="Home Page">Home Page</a></b></li>
<li><a class="internallink" href="Search.aspx?FullText=1" title="Advanced Search">Advanced Search</a></li>
<li><a class="systemlink" href="Category.aspx" title="Categories">Categories</a></li>
<li><a class="systemlink" href="AllPages.aspx" title="All Pages (141)">All Pages (141)</a></li>
<li><a class="pagelink" href="RecentChanges.ashx" title="Recent Changes">Recent Changes</a></li>
<li><a class="pagelink" href="Resources.ashx" title="Resource links">Resource links</a></li>
<li><a class="pagelink" href="LINQBooks.ashx" title="LINQ Books">LINQ Books</a></li>
</ul>
<p><a id="F_Minute_Overviews_1"></a><br />
<h3 class="separator">5 Minute Overviews</h3>
<p> </p>
<ul>
<li><a class="pagelink" href="LinqToObjects5MinuteOVerview.ashx" title="LINQ to Objects">LINQ to Objects</a></li>
<li><a class="pagelink" href="LinqToSQL5MinuteOVerview.ashx" title="LINQ to SQL">LINQ to SQL</a></li>
<li><a class="pagelink" href="LinqToXML5MinuteOVerview.ashx" title="LINQ to XML">LINQ to XML</a></li>
</ul>
<p><a id="FAQ_new_2"></a><br />
<h3 class="separator">FAQ (new)</h3>
<p> </p>
<ul>
<li><a class="pagelink" href="LinqToObjectsFAQ.ashx" title="LINQ to Objects">LINQ to Objects</a></li>
<li><a class="pagelink" href="LinqToSQLFAQ.ashx" title="LINQ to SQL">LINQ to SQL</a></li>
<li><a class="pagelink" href="LinqToXMLFAQ.ashx" title="LINQ to XML">LINQ to XML</a></li>
</ul>
<p><a id="Content_3"></a><br />
<h3 class="separator">Content</h3>
<p></p>
<ul>
<li><a class="systemlink" href="Login.aspx" title="Login/Logout">Login/Logout</a></li>
<li><a class="systemlink" href="Language.aspx" title="Language Selection">Language Selection</a></li>
<li><a class="systemlink" href="Profile.aspx" title="Your Profile">Your Profile</a></li>
<li><a class="systemlink" href="Register.aspx" title="Create Account">Create Account</a></li>
</ul>
<p>
<ul>
<li><a class="systemlink" href="Edit.aspx" title="Create a new Page">Create a new Page</a></li>
<li><a class="systemlink" href="Upload.aspx" title="File Management">File Management</a></li>
<li><a class="externallink" href="http://www.screwturn.eu/PageEditing.ashx" title="Editing Help" target="_blank">Editing Help</a></li>
<li><a class="pagelink" href="Sandbox.ashx" title="Practise Editing">Practise Editing</a></li>
<li><a class="pagelink" href="AboutThisSite.ashx" title="About this Site">About this Site</a></li>
<li><a class="pagelink" href="TroyMagennis.ashx" title="Contact me">Contact me</a></li>
</ul>
<p>
<ul>
<li><a class="systemlink" href="Admin.aspx" title="Administration">Administration</a></li>
</ul>
<p><a href="http://www.screwturn.eu" title="PoweredBy" target="_blank"><img src="Images/PoweredBy.png" alt="PoweredBy" /></a></p></div>
<div id="SidebarFooterDiv">
                    <!-- Used for layout purposes only -->
                </div>
<div></p>
</div></div>
<div id="MainDiv">
<div id="MainHeaderDiv">
                    <!-- Used for layout purposes only -->
                </div>
<p>    &lt;!&#8211;<br />
        function __ShowAllTrail() {<br />
            try {<br />
                document.getElementById(&quot;BreadcrumbsDivMin&quot;).style[&quot;display&quot;] = &quot;none&quot;;<br />
                document.getElementById(&quot;BreadcrumbsDivAll&quot;).style[&quot;display&quot;] = &quot;&quot;;<br />
                __SetStatus(&quot;1&quot;);<br />
            }<br />
            catch(ex) { }<br />
            return false;<br />
        }<br />
        function __HideTrail() {<br />
            try {<br />
                document.getElementById(&quot;BreadcrumbsDivMin&quot;).style[&quot;display&quot;] = &quot;&quot;;<br />
                document.getElementById(&quot;BreadcrumbsDivAll&quot;).style[&quot;display&quot;] = &quot;none&quot;;<br />
                __SetStatus(&quot;0&quot;);<br />
            }<br />
            catch(ex) { }<br />
            return false;<br />
        }</p>
<p>        function __CreateCookie(name, value, days) {<br />
	        if(days) {<br />
		        var date = new Date();<br />
		        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));<br />
		        var expires = &quot;; expires=&quot; + date.toGMTString();<br />
	        }<br />
	        else var expires = &quot;&quot;;<br />
	        document.cookie = name + &quot;=&quot; + value + expires + &quot;; path=&quot; + __cookiePath;<br />
        }</p>
<p>        function __ReadCookie(name) {<br />
	        var nameEQ = name + &quot;=&quot;;<br />
	        var ca = document.cookie.split(&#039;;&#039;);<br />
	        for(var i =0; i </p>
<p>    <a id="PageTop"></a>
<div id="PageHeaderDiv">
<div id="EditHistoryLinkDiv"><a id="DiscussLink" href="LINQtoObjects5MinuteOverview.ashx?Discuss=1&amp;NoRedirect=1">Discuss (8)</a><a id="ViewCodeLink" href="LINQtoObjects5MinuteOverview.ashx?Code=1">View Page Code</a><a id="HistoryLink" href="History.aspx?Page=LINQtoObjects5MinuteOverview">History</a></div>
<h1 class="pagetitle">LINQ to Objects &#8211; 5 Minute Overview</h1>
<div id="PageLockedDiv">This Page is locked</div>
<div id="PrintLinkDiv"><a id="PrintLink" href="Print.aspx?Page=LINQtoObjects5MinuteOverview" target="_blank" title="Printer friendly version">Print</a></div>
<div id="RssLinkDiv"><a id="RssLink" href="RSS.aspx?Page=LINQtoObjects5MinuteOverview" title="Update notifications for this Page (RSS 2.0)">RSS</a></div>
<div id="PageInfoDiv">Modified: 2008/04/24 23:15 by <a href="Message.aspx?Username=t_magennis">t_magennis</a> &#8211; Categorized as: <a href="AllPages.aspx?Cat=LINQ%20to%20Objects">LINQ to Objects</a>, <a href="AllPages.aspx?Cat=Samples">Samples</a></div>
<div id="BreadcrumbsDiv">
<div id="BreadcrumbsDivMin">&raquo; <b><a href="LINQtoObjects5MinuteOverview.ashx">LINQ to Objects &#8211; 5 Minute Overview</a> </b>&raquo; <a href="LINQtoObjects.ashx">LINQ to Objects</a> </div>
<div id="BreadcrumbsDivAll" style="display:none;"><a href="#" title="Click here to hide the Breadcrumbs Trail">[X]</a> &raquo; <b><a href="LINQtoObjects5MinuteOverview.ashx">LINQ to Objects &#8211; 5 Minute Overview</a> </b>&raquo; <a href="LINQtoObjects.ashx">LINQ to Objects</a> </div>
</div>
</div>
<div id="PageContentDiv"><i>I want feedback on this article. Please leave your comments in the discussion page (click on the <b>Discuss</b> button on the top-right of this page)</i></p>
<p>(See also: <a class="pagelink" href="LINQtoObjects.ashx" title="Main LINQ to Objects Page">Main LINQ to Objects Page</a>) </p>
<div class="box"><b>Popular Pages</b></p>
<p><a class="pagelink" href="LINQOverview.ashx" title="What is LINQ?">What is LINQ?</a><br />
<a class="pagelink" href="LINQtoObjects5MinuteOverview.ashx" title="LINQ to Objects - 5 minute overview">LINQ to Objects &#8211; 5 minute overview</a><br />
<a class="pagelink" href="LINQtoSQL5MinuteOverview.ashx" title="LINQ to SQL - 5 minute overview">LINQ to SQL &#8211; 5 minute overview</a><br />
<a class="pagelink" href="LINQtoXML5MinuteOverview.ashx" title="LINQ to XML- 5 minute overview">LINQ to XML- 5 minute overview</a><br />
<a class="pagelink" href="WriteLINQQueries.ashx" title="Writing LINQ Queries">Writing LINQ Queries</a><img src="GetFile.aspx?File=Images%2fUpdated.PNG" alt="Updated" /></div>
<p>LINQ to Objects allows .NET developers to write “queries” over collections of objects.  Out of the box there is a large set of query operators that provide a similar depth of functionality to what we expect from any SQL language working with a relational database, and if what we need isn’t present out-of-the-box, we can add our own. </p>
<p>Traditionally, working with collections of objects meant writing a lot of looping code using for loops or foreach loops to iterate through a list carrying out filtering using if statements, and some action like keeping a running sum of a total property. LINQ frees you from having to write looping code; it allows you to write queries that filter a list or calculate aggregate functions on elements in a collection as a set.</p>
<p>We can write queries against any collection type that implements an interface called IEnumerable (and also a new interface called IQueryable, but more on that later). This is almost any collection type built into the .NET class libraries including simple arrays like string[], or int[], and any List&lt;T&gt; collection we define. Let us look at a few of the simplest examples to understand the basic syntax.</p>
<pre class="csharp"><span style="color:#FF0000;">int</span><span style="color:#000000;">&#91;</span><span style="color:#000000;">&#93;</span> nums = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color:#008000;">new</span></a> <span style="color:#FF0000;">int</span><span style="color:#000000;">&#91;</span><span style="color:#000000;">&#93;</span> <span style="color:#000000;">&#123;</span><span style="color:#FF0000;">0</span>,<span style="color:#FF0000;">4</span>,<span style="color:#FF0000;">2</span>,<span style="color:#FF0000;">6</span>,<span style="color:#FF0000;">3</span>,<span style="color:#FF0000;">8</span>,<span style="color:#FF0000;">3</span>,<span style="color:#FF0000;">1</span><span style="color:#000000;">&#125;</span>;

&nbsp;
&nbsp;
var result = from n <span style="color:#0600FF;">in</span> nums
             where n &lt; <span style="color:#FF0000;">5</span>
             orderby n
             select n;
&nbsp;
&nbsp;
<span style="color:#0600FF;">foreach</span><span style="color:#000000;">&#40;</span><span style="color:#FF0000;">int</span> i <span style="color:#0600FF;">in</span> result<span style="color:#000000;">&#41;</span>

    Console.<span style="color:#0000FF;">WriteLine</span><span style="color:#000000;">&#40;</span>i<span style="color:#000000;">&#41;</span>;
&nbsp;
&nbsp;
Output:
<span style="color:#FF0000;">0</span>
<span style="color:#FF0000;">1</span>
<span style="color:#FF0000;">2</span>
<span style="color:#FF0000;">3</span>
<span style="color:#FF0000;">3</span>	

<span style="color:#FF0000;">4</span></pre>
<p>An example of calculating the aggregate sum of all the elements would look like –</p>
<pre class="csharp"><span style="color:#FF0000;">int</span><span style="color:#000000;">&#91;</span><span style="color:#000000;">&#93;</span> nums = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color:#008000;">new</span></a> <span style="color:#FF0000;">int</span><span style="color:#000000;">&#91;</span><span style="color:#000000;">&#93;</span> <span style="color:#000000;">&#123;</span><span style="color:#FF0000;">0</span>,<span style="color:#FF0000;">4</span>,<span style="color:#FF0000;">2</span>,<span style="color:#FF0000;">6</span>,<span style="color:#FF0000;">3</span>,<span style="color:#FF0000;">8</span>,<span style="color:#FF0000;">3</span>,<span style="color:#FF0000;">1</span><span style="color:#000000;">&#125;</span>;

&nbsp;
<span style="color:#FF0000;">int</span> result = nums.<span style="color:#0000FF;">Sum</span><span style="color:#000000;">&#40;</span><span style="color:#000000;">&#41;</span>;
Console.<span style="color:#0000FF;">WriteLine</span><span style="color:#000000;">&#40;</span>result<span style="color:#000000;">&#41;</span>;
&nbsp;
Output:
<span style="color:#FF0000;">27</span></pre>
<p>LINQ to Objects extends any type that inherits from IEnumerable (which is almost every collection class in .NET, from simple Arrays to List&lt;T&gt;) to support query operations similar to those available in SQL. We can write queries using any of the built-in Standard Query Operators, or add our own operators if we need to.  The standard operators cover a wide variety of categories, at present there are over fifty that form the backbone of LINQ. To get an idea of their scope, here is a list of those operators available to us -</p>
<div class="box">
<table>
<tr>
<td><b>Operator Type</b></td>
<td><b>Operator Name</b></td>
</tr>
<tr>
<td>Aggregation</td>
<td><a class="pagelink" href="AggregateOperator.ashx" title="Aggregate">Aggregate</a>, <a class="pagelink" href="AverageOperator.ashx" title="Average">Average</a>, <a class="pagelink" href="CountOperator.ashx" title="Count">Count</a>, <a class="pagelink" href="LongCountOperator.ashx" title="LongCount">LongCount</a>, <a class="pagelink" href="MaxOperator.ashx" title="Max">Max</a>, <a class="pagelink" href="MinOperator.ashx" title="Min">Min</a>, <a class="pagelink" href="SumOperator.ashx" title="Sum">Sum</a></td>
</tr>
<tr>
<td>Conversion</td>
<td><a class="pagelink" href="CastOperator.ashx" title="Cast">Cast</a>, <a class="pagelink" href="OfTypeOperator.ashx" title="OfType">OfType</a>, <a class="pagelink" href="ToArrayOperator.ashx" title="ToArray">ToArray</a>, <a class="pagelink" href="ToDictionaryOperator.ashx" title="ToDictionary">ToDictionary</a>, <a class="pagelink" href="ToListOperator.ashx" title="ToList">ToList</a>, <a class="pagelink" href="ToLookupOperator.ashx" title="ToLookup">ToLookup</a>, <a class="pagelink" href="ToSequenceOperator.ashx" title="ToSequence">ToSequence</a></td>
</tr>
<tr>
<td>Element</td>
<td><a class="pagelink" href="DefaultIfEmptyOperator.ashx" title="DefaultIfEmpty">DefaultIfEmpty</a>, <a class="pagelink" href="ElementAtOperator.ashx" title="ElementAt">ElementAt</a>, <a class="pagelink" href="ElementAtOrDefaultOperator.ashx" title="ElementAtOrDefault">ElementAtOrDefault</a>, <a class="pagelink" href="FirstOperator.ashx" title="First">First</a>, <a class="pagelink" href="FirstOrDefaultOperator.ashx" title="FirstOrDefault">FirstOrDefault</a>, <a class="pagelink" href="LastOperator.ashx" title="Last">Last</a>, <a class="pagelink" href="LastOrDefaultOperator.ashx" title="LastOrDefault">LastOrDefault</a>, <a class="pagelink" href="SingleOperator.ashx" title="Single">Single</a>, <a class="pagelink" href="SingleOrDefaultOperator.ashx" title="SingleOrDefault">SingleOrDefault</a></td>
</tr>
<tr>
<td>Equality</td>
<td><a class="pagelink" href="EqualAllOperator.ashx" title="EqualAll">EqualAll</a></td>
</tr>
<tr>
<td>Generation</td>
<td><a class="pagelink" href="EmptyOperator.ashx" title="Empty">Empty</a>, <a class="pagelink" href="RangeOperator.ashx" title="Range">Range</a>, <a class="pagelink" href="RepeatOperator.ashx" title="Repeat">Repeat</a></td>
</tr>
<tr>
<td>Grouping</td>
<td><a class="pagelink" href="GroupByOperator.ashx" title="GroupBy">GroupBy</a></td>
</tr>
<tr>
<td>Joining</td>
<td><a class="pagelink" href="GroupJoinOperator.ashx" title="GroupJoin">GroupJoin</a>, <a class="pagelink" href="JoinOperator.ashx" title="Join">Join</a></td>
</tr>
<tr>
<td>Ordering</td>
<td><a class="pagelink" href="OrderByOperator.ashx" title="OrderBy">OrderBy</a>, <a class="pagelink" href="ThenByOperator.ashx" title="ThenBy">ThenBy</a>, <a class="pagelink" href="OrderByDescendingOperator.ashx" title="OrderByDescending">OrderByDescending</a>, <a class="pagelink" href="ThenByDescendingOperator.ashx" title="ThenByDescending">ThenByDescending</a>, <a class="pagelink" href="ReverseOperator.ashx" title="Reverse">Reverse</a></td>
</tr>
<tr>
<td>Partitioning</td>
<td><a class="pagelink" href="SkipOperator.ashx" title="Skip">Skip</a>, <a class="pagelink" href="SkipWhileOperator.ashx" title="SkipWhile">SkipWhile</a>, <a class="pagelink" href="TakeOperator.ashx" title="Take">Take</a>, <a class="pagelink" href="TakeWhileOperator.ashx" title="TakeWhile">TakeWhile</a></td>
</tr>
<tr>
<td>Quantifiers</td>
<td><a class="pagelink" href="AllOperator.ashx" title="All">All</a>, <a class="pagelink" href="AnyOperator.ashx" title="Any">Any</a>, <a class="pagelink" href="ContainsOperator.ashx" title="Contains">Contains</a></td>
</tr>
<tr>
<td>Restriction</td>
<td><a class="pagelink" href="WhereOperator.ashx" title="Where">Where</a></td>
</tr>
<tr>
<td>Selection</td>
<td><a class="pagelink" href="SelectOperator.ashx" title="Select">Select</a>, <a class="pagelink" href="SelectManyOperator.ashx" title="SelectMany">SelectMany</a></td>
</tr>
<tr>
<td>Set</td>
<td><a class="pagelink" href="ConcatOperator.ashx" title="Concat">Concat</a>, <a class="pagelink" href="DistinctOperator.ashx" title="Distinct">Distinct</a>, <a class="pagelink" href="ExceptOperator.ashx" title="Except">Except</a>, <a class="pagelink" href="IntersectOperator.ashx" title="Intersect">Intersect</a>, <a class="pagelink" href="UnionOperator.ashx" title="Union">Union</a></td>
</tr>
</table>
</div>
<p></p>
<p>Most of the operators should be familiar if you have ever worked with a relational database writing queries in SQL. One important distinction between writing SQL queries and LINQ queries is that the operator order is reversed. If you are used to Select-From-Where-OrderBy, it might take some time to overcome the muscle memory and move to From-Where-OrderBy-Select.</p>
<p>To demonstrate some of LINQ’s query capabilities let us write a few queries over this data.</p>
<div class="box">
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>D.O.B.</th>
<th>Phone</th>
<th>State</th>
</tr>
<tr>
<td>Barney</td>
<td>Gottshall</td>
<td>19-Oct-1945</td>
<td>885 983 8858</td>
<td>CA</td>
</tr>
<tr>
<td>Armando</td>
<td>Valdes</td>
<td>9-Dec-1973</td>
<td>848 553 8487</td>
<td>WA</td>
</tr>
<tr>
<td>Adam</td>
<td>Gauwain</td>
<td>3-Oct-1959</td>
<td>115 999 1154</td>
<td>AK</td>
</tr>
<tr>
<td>Jeffery</td>
<td>Deane</td>
<td>16-Dec-1950</td>
<td>677 602 6774</td>
<td>CA</td>
</tr>
<tr>
<td>Collin</td>
<td>Zeeman</td>
<td>10-Feb-1935</td>
<td>603 303 6030</td>
<td>FL</td>
</tr>
<tr>
<td>Stewart</td>
<td>Kagel</td>
<td>20-Feb-1950</td>
<td>546 607 5462</td>
<td>WA</td>
</tr>
<tr>
<td>Chance</td>
<td>Lard</td>
<td>21-Oct-1951</td>
<td>278 918 2789</td>
<td>WA</td>
</tr>
<tr>
<td>Blaine</td>
<td>Reifsteck</td>
<td>18-May-1946</td>
<td>715 920 7157</td>
<td>TX</td>
</tr>
<tr>
<td>Mack</td>
<td>Kamph</td>
<td>17-Sep-1977</td>
<td>364 202 3644</td>
<td>TX</td>
</tr>
<tr>
<td>Ariel</td>
<td>Hazelgrove</td>
<td>23-May-1922</td>
<td>165 737 1656</td>
<td>OR </td>
</tr>
</table>
</div>
<p><b>Sample Contact data</b></p>
<pre class="csharp">List&lt;Contacts&gt; contacts = Contacts.<span style="color:#0000FF;">SampleData</span><span style="color:#000000;">&#40;</span><span style="color:#000000;">&#41;</span>;

&nbsp;
var q = from c <span style="color:#0600FF;">in</span> contacts
        where c.<span style="color:#0000FF;">DateOfBirth</span>.<span style="color:#0000FF;">AddYears</span><span style="color:#000000;">&#40;</span><span style="color:#FF0000;">35</span><span style="color:#000000;">&#41;</span> &gt; DateTime.<span style="color:#0000FF;">Now</span>
        orderby c.<span style="color:#0000FF;">DateOfBirth</span> descending
        select c.<span style="color:#0000FF;">FirstName</span> + <span style="color:#808080;">&quot; &quot;</span> + c.<span style="color:#0000FF;">LastName</span> +
               <span style="color:#808080;">&quot; b.&quot;</span> + c.<span style="color:#0000FF;">DateOfBirth</span>.<span style="color:#0000FF;">ToString</span><span style="color:#000000;">&#40;</span><span style="color:#808080;">&quot;dd-MMM-yyyy&quot;</span><span style="color:#000000;">&#41;</span>;

&nbsp;
<span style="color:#0600FF;">foreach</span><span style="color:#000000;">&#40;</span><span style="color:#FF0000;">string</span> s <span style="color:#0600FF;">in</span> q<span style="color:#000000;">&#41;</span>
    Console.<span style="color:#0000FF;">WriteLine</span><span style="color:#000000;">&#40;</span>s<span style="color:#000000;">&#41;</span>;
&nbsp;
Output:
Mack Kamph b<span style="color:#FF0000;">.17</span>-Sep<span style="color:#FF0000;">-1977</span>

Armando Valdes b<span style="color:#FF0000;">.09</span>-Dec<span style="color:#FF0000;">-1973</span></pre>
<p>
The previous example demonstrates how to get a list of contacts who are less than 35 years of age sorted in descending order by age. This query builds a list of formatted strings as the result, but any type can be returned, even an anonymous type (a type we haven’t explicitly defined that holds just our data, but more on that later). Figure 6 demonstrates grouping, which allows you to create a sub-collection of elements based on a value by using the group by construct. </p>
<pre class="csharp">List&lt;Contacts&gt; contacts = Contacts.<span style="color:#0000FF;">SampleData</span><span style="color:#000000;">&#40;</span><span style="color:#000000;">&#41;</span>;
&nbsp;
var q = from c <span style="color:#0600FF;">in</span> contacts
        group c by c.<span style="color:#0000FF;">State</span>;

&nbsp;
<span style="color:#0600FF;">foreach</span><span style="color:#000000;">&#40;</span>var group <span style="color:#0600FF;">in</span> q<span style="color:#000000;">&#41;</span> <span style="color:#000000;">&#123;</span>
    Console.<span style="color:#0000FF;">WriteLine</span><span style="color:#000000;">&#40;</span><span style="color:#808080;">&quot;State: &quot;</span> + group.<span style="color:#0000FF;">Key</span><span style="color:#000000;">&#41;</span>;
        <span style="color:#0600FF;">foreach</span><span style="color:#000000;">&#40;</span>Contacts c <span style="color:#0600FF;">in</span> group<span style="color:#000000;">&#41;</span>

            Console.<span style="color:#0000FF;">WriteLine</span><span style="color:#000000;">&#40;</span><span style="color:#808080;">&quot;  {0) {1}&quot;</span>, c.<span style="color:#0000FF;">FirstName</span>, c.<span style="color:#0000FF;">LastName</span><span style="color:#000000;">&#41;</span>;
<span style="color:#000000;">&#125;</span>
&nbsp;
Output:
State: CA
  Barney Gottshall
  Jeffery Deane
State: WA
  Armando Valdes
  Stewart Kagel
  Chance Lard
State: AK
  Adam Gauwain
State: FL
  Collin Zeeman
State: TX
  Blaine Reifsteck
  Mack Kamph
State: OR
  Ariel Hazelgrove</pre>
<p>
A key aspect of accessing relational data is the concept of joining.  SQL languages have powerful join capabilities to allow queries to be written against normalized data which is a fancy term for not repeating data, by separating data across multiple tables linking by a common value. LINQ allows you to join multiple object collections together using syntax similar to SQL. To demonstrate, in addition to the data shown in <i>Sample Contact data</i>, also consider the following call log data.</p>
<div class="box">
<table>
<tr>
<th>Number</th>
<th>Duration (mins)</th>
<th>Incoming</th>
<th>Date</th>
<th>Time</th>
</tr>
<tr>
<td>885 983 8858</td>
<td>2</td>
<td>TRUE</td>
<td>7-Aug-2006</td>
<td>8:12</td>
</tr>
<tr>
<td>165 737 1656</td>
<td>15</td>
<td>TRUE</td>
<td>7-Aug-2006</td>
<td>9:23</td>
</tr>
<tr>
<td>364 202 3644</td>
<td>1</td>
<td>FALSE</td>
<td>7-Aug-2006</td>
<td>10:5</td>
</tr>
<tr>
<td>603 303 6030</td>
<td>2</td>
<td>FALSE</td>
<td>7-Aug-2006</td>
<td>10:35</td>
</tr>
<tr>
<td>546 607 5462</td>
<td>4</td>
<td>TRUE</td>
<td>7-Aug-2006</td>
<td>11:15</td>
</tr>
<tr>
<td>885 983 8858</td>
<td>15</td>
<td>FALSE</td>
<td>7-Aug-2006</td>
<td>13:12</td>
</tr>
<tr>
<td>885 983 8858</td>
<td>3</td>
<td>TRUE</td>
<td>7-Aug-2006</td>
<td>13:47</td>
</tr>
<tr>
<td>546 607 5462</td>
<td>1</td>
<td>FALSE</td>
<td>7-Aug-2006</td>
<td>20:34</td>
</tr>
<tr>
<td>546 607 5462</td>
<td>3</td>
<td>FALSE</td>
<td>8-Aug-2006</td>
<td>10:10</td>
</tr>
<tr>
<td>603 303 6030</td>
<td>23</td>
<td>FALSE</td>
<td>8-Aug-2006</td>
<td>10:40</td>
</tr>
<tr>
<td>848 553 8487</td>
<td>3</td>
<td>FALSE</td>
<td>8-Aug-2006</td>
<td>14:0</td>
</tr>
<tr>
<td>848 553 8487</td>
<td>7</td>
<td>TRUE</td>
<td>8-Aug-2006</td>
<td>14:37</td>
</tr>
<tr>
<td>278 918 2789</td>
<td>6</td>
<td>TRUE</td>
<td>8-Aug-2006</td>
<td>15:23</td>
</tr>
<tr>
<td>364 202 3644</td>
<td>20</td>
<td>TRUE</td>
<td>8-Aug-2006</td>
<td>17:12</td>
</tr>
</table>
</div>
<p><b>Sample Call Log data</b></p>
<p>To join the call log data and retrieve the contact name that matches the phone number we would use the following query.</p>
<pre class="csharp">&nbsp;
    List&lt;Contacts&gt; contacts = Contacts.<span style="color:#0000FF;">SampleData</span><span style="color:#000000;">&#40;</span><span style="color:#000000;">&#41;</span>;
    List&lt;CallLog&gt; callLog = CallLog.<span style="color:#0000FF;">SampleData</span><span style="color:#000000;">&#40;</span><span style="color:#000000;">&#41;</span>;
&nbsp;
&nbsp;
    var q = from call <span style="color:#0600FF;">in</span> callLog
            join contact <span style="color:#0600FF;">in</span> contacts on call.<span style="color:#0000FF;">Number</span> equals contact.<span style="color:#0000FF;">Phone</span>

            select <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color:#008000;">new</span></a> <span style="color:#000000;">&#123;</span>contact.<span style="color:#0000FF;">FirstName</span>, contact.<span style="color:#0000FF;">LastName</span>,
                        call.<span style="color:#0000FF;">When</span>, call.<span style="color:#0000FF;">Duration</span><span style="color:#000000;">&#125;</span>;

     <span style="color:#0600FF;">foreach</span><span style="color:#000000;">&#40;</span>var call <span style="color:#0600FF;">in</span> q<span style="color:#000000;">&#41;</span>

         Console.<span style="color:#0000FF;">WriteLine</span><span style="color:#000000;">&#40;</span>“<span style="color:#000000;">&#123;</span><span style="color:#FF0000;">0</span><span style="color:#000000;">&#125;</span> – <span style="color:#000000;">&#123;</span><span style="color:#FF0000;">1</span><span style="color:#000000;">&#41;</span> <span style="color:#000000;">&#123;</span><span style="color:#FF0000;">2</span><span style="color:#000000;">&#41;</span> <span style="color:#000000;">&#40;</span><span style="color:#000000;">&#123;</span><span style="color:#FF0000;">3</span><span style="color:#000000;">&#125;</span>min<span style="color:#000000;">&#41;</span>”,
                           call.<span style="color:#0000FF;">When</span>.<span style="color:#0000FF;">ToString</span><span style="color:#000000;">&#40;</span><span style="color:#808080;">&quot;ddMMM HH:m&quot;</span><span style="color:#000000;">&#41;</span>,
                           call.<span style="color:#0000FF;">FirstName</span>, call.<span style="color:#0000FF;">LastName</span>, call.<span style="color:#0000FF;">Duration</span><span style="color:#000000;">&#41;</span>;

&nbsp;
Output:
07Aug <span style="color:#FF0000;">08</span>:<span style="color:#FF0000;">12</span> - Barney Gottshall <span style="color:#000000;">&#40;</span>2min<span style="color:#000000;">&#41;</span>
07Aug <span style="color:#FF0000;">09</span>:<span style="color:#FF0000;">23</span> - Ariel Hazelgrove <span style="color:#000000;">&#40;</span>15min<span style="color:#000000;">&#41;</span>

07Aug <span style="color:#FF0000;">10</span>:<span style="color:#FF0000;">5</span> - Mack Kamph <span style="color:#000000;">&#40;</span>1min<span style="color:#000000;">&#41;</span>
07Aug <span style="color:#FF0000;">10</span>:<span style="color:#FF0000;">35</span> - Collin Zeeman <span style="color:#000000;">&#40;</span>2min<span style="color:#000000;">&#41;</span>
07Aug <span style="color:#FF0000;">11</span>:<span style="color:#FF0000;">15</span> - Stewart Kagel <span style="color:#000000;">&#40;</span>4min<span style="color:#000000;">&#41;</span>

07Aug <span style="color:#FF0000;">13</span>:<span style="color:#FF0000;">12</span> - Barney Gottshall <span style="color:#000000;">&#40;</span>15min<span style="color:#000000;">&#41;</span>
07Aug <span style="color:#FF0000;">13</span>:<span style="color:#FF0000;">47</span> - Barney Gottshall <span style="color:#000000;">&#40;</span>3min<span style="color:#000000;">&#41;</span>
07Aug <span style="color:#FF0000;">20</span>:<span style="color:#FF0000;">34</span> - Stewart Kagel <span style="color:#000000;">&#40;</span>1min<span style="color:#000000;">&#41;</span>

08Aug <span style="color:#FF0000;">10</span>:<span style="color:#FF0000;">10</span> - Stewart Kagel <span style="color:#000000;">&#40;</span>3min<span style="color:#000000;">&#41;</span>
08Aug <span style="color:#FF0000;">10</span>:<span style="color:#FF0000;">40</span> - Collin Zeeman <span style="color:#000000;">&#40;</span>23min<span style="color:#000000;">&#41;</span>
08Aug <span style="color:#FF0000;">14</span>:<span style="color:#FF0000;">0</span> - Armando Valdes <span style="color:#000000;">&#40;</span>3min<span style="color:#000000;">&#41;</span>

08Aug <span style="color:#FF0000;">14</span>:<span style="color:#FF0000;">37</span> - Armando Valdes <span style="color:#000000;">&#40;</span>7min<span style="color:#000000;">&#41;</span>
08Aug <span style="color:#FF0000;">15</span>:<span style="color:#FF0000;">23</span> - Chance Lard <span style="color:#000000;">&#40;</span>6min<span style="color:#000000;">&#41;</span>
08Aug <span style="color:#FF0000;">17</span>:<span style="color:#FF0000;">12</span> - Mack Kamph <span style="color:#000000;">&#40;</span>20min<span style="color:#000000;">&#41;</span></pre>
<p></p>
<p><b>This query joins call records with contact data via the phone number.</b></p>
<p>Going one step further and summarizing data from multiple collections by combining filtering, grouping, joining and aggregate functions all in one query expression, we can demonstrate the power of Query Expressions on in-memory data. The following example show incoming call records from each contact and the aggregate call statistics.</p>
<pre class="csharp">    List&lt;Contacts&gt; contacts = Contacts.<span style="color:#0000FF;">SampleData</span><span style="color:#000000;">&#40;</span><span style="color:#000000;">&#41;</span>;
    List&lt;CallLog&gt; callLog = CallLog.<span style="color:#0000FF;">SampleData</span><span style="color:#000000;">&#40;</span><span style="color:#000000;">&#41;</span>;
&nbsp;

    var q = from call <span style="color:#0600FF;">in</span> callLog
            where call.<span style="color:#0000FF;">Incoming</span> == <span style="color:#0600FF;">true</span>
            group call by call.<span style="color:#0000FF;">Number</span> into g
            join contact <span style="color:#0600FF;">in</span> contacts on g.<span style="color:#0000FF;">Key</span> equals contact.<span style="color:#0000FF;">Phone</span>

            orderby contact.<span style="color:#0000FF;">FirstName</span>, contact.<span style="color:#0000FF;">LastName</span>
            select <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color:#008000;">new</span></a> <span style="color:#000000;">&#123;</span> contact.<span style="color:#0000FF;">FirstName</span>, contact.<span style="color:#0000FF;">LastName</span>,
                         Count = g.<span style="color:#0000FF;">Count</span><span style="color:#000000;">&#40;</span><span style="color:#000000;">&#41;</span>,
                         Avg   = g.<span style="color:#0000FF;">Average</span><span style="color:#000000;">&#40;</span> c =&gt; c.<span style="color:#0000FF;">Duration</span> <span style="color:#000000;">&#41;</span>,
                         Total = g.<span style="color:#0000FF;">Sum</span><span style="color:#000000;">&#40;</span> c =&gt; c.<span style="color:#0000FF;">Duration</span> <span style="color:#000000;">&#41;</span><span style="color:#000000;">&#125;</span>;

    <span style="color:#0600FF;">foreach</span><span style="color:#000000;">&#40;</span>var call <span style="color:#0600FF;">in</span> q<span style="color:#000000;">&#41;</span>

        Console.<span style="color:#0000FF;">WriteLine</span><span style="color:#000000;">&#40;</span><span style="color:#808080;">&quot;{0} {1} - Calls:{2}, Time:{3}mins, Avg:{4}mins&quot;</span>,
            call.<span style="color:#0000FF;">FirstName</span>, call.<span style="color:#0000FF;">LastName</span>,
            call.<span style="color:#0000FF;">Count</span>, call.<span style="color:#0000FF;">Total</span>, Math.<span style="color:#0000FF;">Round</span><span style="color:#000000;">&#40;</span>call.<span style="color:#0000FF;">Avg</span>, <span style="color:#FF0000;">2</span><span style="color:#000000;">&#41;</span><span style="color:#000000;">&#41;</span>;

&nbsp;
Output:
Ariel Hazelgrove - Calls:<span style="color:#FF0000;">1</span>, Time:15mins, Avg:15mins
Armando Valdes - Calls:<span style="color:#FF0000;">1</span>, Time:7mins, Avg:7mins
Barney Gottshall - Calls:<span style="color:#FF0000;">2</span>, Time:5mins, Avg:<span style="color:#FF0000;">2</span>.5mins
Chance Lard - Calls:<span style="color:#FF0000;">1</span>, Time:6mins, Avg:6mins
Mack Kamph - Calls:<span style="color:#FF0000;">1</span>, Time:20mins, Avg:20mins
Stewart Kagel - Calls:<span style="color:#FF0000;">1</span>, Time:4mins, Avg:4mins</pre>
<p></p>
<p><b>This example shows filtering, ordering, grouping, joining and selection using aggregate values.</b></p>
<p>(See also: <a class="pagelink" href="LINQtoObjects.ashx" title="Main LINQ to Objects Page">Main LINQ to Objects Page</a>)</p>
<div class="box"><b>Popular Pages</b><br />
<a class="pagelink" href="LINQOverview.ashx" title="What is LINQ?">What is LINQ?</a><br />
<a class="pagelink" href="LINQtoObjects5MinuteOverview.ashx" title="LINQ to Objects - 5 minute overview">LINQ to Objects &#8211; 5 minute overview</a><br />
<a class="pagelink" href="LINQtoSQL5MinuteOverview.ashx" title="LINQ to SQL - 5 minute overview">LINQ to SQL &#8211; 5 minute overview</a><br />
<a class="pagelink" href="LINQtoXML5MinuteOverview.ashx" title="LINQ to XML- 5 minute overview">LINQ to XML- 5 minute overview</a><br />
<a class="pagelink" href="WriteLINQQueries.ashx" title="Writing LINQ Queries">Writing LINQ Queries</a><img src="GetFile.aspx?File=Images%2fUpdated.PNG" alt="Updated" /></div>
<p>LINQ to Object &#8211; 5 Minute Overview is Copyright &copy; Troy Magennis.</p>
</div>
<div id="PageInternalFooterDiv">
</div>
<div id="MainFooterDiv">
                    <!-- Used for layout purposes only -->
                </div>
</p></div>
</p></div>
<div id="FooterDiv">
<p class="small">If you would like to comment on this page, click on the Discuss button located on the top-right of each page. Feel free to edit any mistakes or omissions you find. If you have an objection or find in-appropriate content then contact the <a class="pagelink" href="TroyMagennis.ashx" title="administrator">administrator</a>. This website is not affiliated with Microsoft&reg;, all content and opinions are those of the specific author and some advice, solutions and article may contain unintentional errors &#8211; please use care. Powered by <a class="externallink" href="http://www.screwturn.eu" title="ScrewTurn Wiki" target="_blank">ScrewTurn Wiki</a> version 2.0.33. Some of the icons created by <a class="externallink" href="http://www.famfamfam.com" title="FamFamFam" target="_blank">FamFamFam</a>.</p>
</p></div>
<p>_uacct = &#8220;UA-853541-2&#8243;;<br />
urchinTracker();</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jenifertrinh.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jenifertrinh.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jenifertrinh.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jenifertrinh.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jenifertrinh.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jenifertrinh.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jenifertrinh.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jenifertrinh.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jenifertrinh.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jenifertrinh.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jenifertrinh.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jenifertrinh.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jenifertrinh.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jenifertrinh.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jenifertrinh.wordpress.com&amp;blog=9442160&amp;post=31&amp;subd=jenifertrinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jenifertrinh.wordpress.com/2009/12/04/abc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5691e68acc57a4b0e5ba81afca2d6378?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jenifertrinh</media:title>
		</media:content>
	</item>
		<item>
		<title>Rhythm of the rain</title>
		<link>http://jenifertrinh.wordpress.com/2009/10/06/rhythm-of-the-rain/</link>
		<comments>http://jenifertrinh.wordpress.com/2009/10/06/rhythm-of-the-rain/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 03:42:50 +0000</pubDate>
		<dc:creator>jenifertrinh</dc:creator>
				<category><![CDATA[muzik]]></category>

		<guid isPermaLink="false">http://jenifertrinh.wordpress.com/?p=21</guid>
		<description><![CDATA[Một bài hát trong trẻo và mát lành như cơn mưa mùa hạ. Ca từ buồn nhưng lại làm ngân vang trong lòng người ta những thanh âm reo vui rộn rã theo nhịp điệu của cơn mưa. Mưa như người bạn nhí nhảnh vô tư lự của chàng trai, để chàng trút bao nỗi [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jenifertrinh.wordpress.com&amp;blog=9442160&amp;post=21&amp;subd=jenifertrinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="color:#4a6b8c;font-family:Arial,,新細明體,細明體,MingLiU,PMingLiU;text-align:left;">Một bài hát trong trẻo và mát lành như cơn mưa mùa hạ. Ca từ buồn nhưng lại làm ngân vang trong lòng người ta những thanh âm reo vui rộn rã theo nhịp điệu của cơn mưa. Mưa như người bạn nhí nhảnh vô tư lự của chàng trai, để chàng trút bao nỗi lòng về cuộc tình vừa tan vỡ. Cái cách chàng &#8220;kể tội&#8221; cô gái đã mang trái tim chàng ra đi thật trẻ con: &#8220;Mưa ơi, hãy nói cho tôi nghe xem như thế có công bằng không khi cô ấy đã đánh cắp trái tim tôi mà không hề mảy may bận tâm&#8221; và nỗi ngậm ngùi của chàng cũng thật dễ thương &#8220;Làm sao tôi có thể yêu được một người con gái khác khi trái tim tôi đang ở tận nơi xa nào&#8221;. Bài hát hết rồi mà tiếng mưa vẫn như còn reo vang tí tách tựa những giọt pha lê, bởi tình yêu trong sáng như cơn mưa nên nỗi niềm đau khổ cũng trở nên nhẹ nhàng trong vắt.</p>
<p><span style="font-style:italic;font-weight:bold;">Xin mượn lời bài hát để &#8220;kể tội&#8221; anh, mưa ơi xin hãy là người bạn để lắng nghe tâm sự của tôi.</span></p>
<p>Listen to the rhythm of the falling rain<br />
Telling me just what a fool I&#8217;ve been<br />
<span style="font-weight:bold;font-style:italic;">I wish that it would go and let me cry in vain</span><br />
<span style="font-weight:bold;font-style:italic;">And let me be alone again</span></p>
<p>Tôi lắng nghe giai điệu của mưa<br />
Tiếng mưa như nói với tôi rằng tôi chỉ la một kẻ khờ khạo<br />
<span style="font-style:italic;font-weight:bold;">Mưa ơi xin ngừng rơi để tôi khóc trong đau khổ</span><br />
<span style="font-style:italic;font-weight:bold;">Tôi muốn được cô đơn một mình</span></p>
<p>The only girl I care about has gone away<br />
Looking for a brand new start<br />
But little does she know<br />
That when she left that day<br />
Along with her she took my heart</p>
<p>Người con trai duy nhất mà tôi yêu đã rời xa tôi<br />
Anh tìm kiếm một sự khởi đầu mới mẻ<br />
Người yêu ơi, anh có biết rằng<br />
Ngày anh đi anh đã mang theo cả tình yêu của tôi</p>
<p>Rain please tell me now does that seem fair<br />
<span style="font-style:italic;font-weight:bold;">For her to steal my heart away when she don&#8217;t care</span><br />
<span style="font-style:italic;font-weight:bold;">I can&#8217;t love another when my hearts somewhere far away</span></p>
<p>Mưa ơi hãy nói cho tôi biết điều này có công bằng không<br />
<span style="font-size:small;"><span style="font-weight:bold;font-style:italic;">Anh đánh cắp trái tim tôi khi mà không hề mảy may bận tâm</span></span><br />
<span style="font-style:italic;font-weight:bold;font-size:small;">Làm sao tôi có thể yêu được một người con trai khác khi trái tim tôi đang ở tận nơi xa nào</span></p>
<p>The only girl I care about has gone away<br />
Looking for a brand new start<br />
But little does she know that when she left that day<br />
Along with her she took my heart</p>
<p>Người con trai duy nhất mà tôi yêu đã rời xa tôi<br />
Anh tìm kiếm một sự khởi đầu mới mẻ<br />
Người yêu ơi, anh có biết rằng<br />
Ngày anh đi anh đã mang theo cả tình yêu của tôi</p>
<p>Rain won&#8217;t you tell her that I love her so<br />
Please ask the sun to set her heart aglow<br />
Rain in her heart and let the love we knew start to grow</p>
<p>Mưa nói giùm tôi với anh rằng tôi yêu anh lắm<br />
Xin nói mặt trời thắp lửa trái tim anh<br />
Hãy để mưa rơi trong lòng anh<br />
Và để tình yêu đôi ta ngày trước lại thêm một lần nảy nở</p>
<p>Listen to the rhythm of the falling rain<br />
Telling me just what a fool I&#8217;ve been<br />
I wish that it would go and let me cry in vain<br />
And let me be alone again</p>
<p>Tôi lắng nghe giai điệu của mưa<br />
Tiếng mưa như nói với tôi rằng tôi chỉ la một kẻ khờ khạo<br />
Mưa ơi xin ngừng rơi để tôi khóc trong đau khổ<br />
Tôi muốn được cô đơn một mình</p>
<p>Oh, listen to the falling rain<br />
Pitter pater, pitter pater<br />
Oh, oh, oh, listen to the falling rain<br />
Pitter pater, pitter pater</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jenifertrinh.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jenifertrinh.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jenifertrinh.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jenifertrinh.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jenifertrinh.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jenifertrinh.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jenifertrinh.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jenifertrinh.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jenifertrinh.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jenifertrinh.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jenifertrinh.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jenifertrinh.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jenifertrinh.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jenifertrinh.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jenifertrinh.wordpress.com&amp;blog=9442160&amp;post=21&amp;subd=jenifertrinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jenifertrinh.wordpress.com/2009/10/06/rhythm-of-the-rain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5691e68acc57a4b0e5ba81afca2d6378?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jenifertrinh</media:title>
		</media:content>
	</item>
		<item>
		<title>What are the key difference between ASP.NET Webforms &amp; ASP.NET MVC?</title>
		<link>http://jenifertrinh.wordpress.com/2009/09/11/what-are-the-key-difference-between-asp-net-webforms-asp-net-mvc/</link>
		<comments>http://jenifertrinh.wordpress.com/2009/09/11/what-are-the-key-difference-between-asp-net-webforms-asp-net-mvc/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 23:47:43 +0000</pubDate>
		<dc:creator>jenifertrinh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jenifertrinh.wordpress.com/?p=19</guid>
		<description><![CDATA[Here are some points that differentiate ASP.NET Web Forms from ASP.NET MVC: Webform Uses the ‘Page Controller’ pattern. Each page has a code-behind class that acts as a controller and is responsible for rendering the layout. MVC Uses the ‘Front Controller’ pattern. There is a single central controller for all pages to process web application [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jenifertrinh.wordpress.com&amp;blog=9442160&amp;post=19&amp;subd=jenifertrinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here are some points that differentiate ASP.NET Web Forms from ASP.NET MVC:</p>
<ol>
<li>Webform Uses the ‘Page Controller’ pattern. Each page has a code-behind class that acts as a controller and is responsible for rendering the layout. MVC Uses the ‘Front Controller’ pattern. There is a single central controller for all pages to process web application requests and facilitates a rich routing architecture.</li>
<li>Webform Uses an architecture that combines the Controller (code behind) and the View (.aspx). Thus the Controller has a dependency on the View. Due to this, testing and maintainability becomes an issue. MVC enforces a &#8220;separation of concerns&#8221;. The Model does not know anything about the View. The View does not know there’s a Controller. This makes MVC applications easier to test and maintain.</li>
<li>In Webform the view is called before the controller, while in MVC Controller renders View based on actions as a result of the User Interactions on the UI.</li>
<li>At Webforms core, you ‘cannot’ test your controller without instantiating a View. There are ways to get around it using tools. While ASP.NET MVC was designed to make test-driven development easier. You ‘can’ test your Controller without instantiating a View and carry out unit-tests without having to run the controllers in an ASP.NET process.</li>
<li>WebForms manage state by using Viewstate and server-based controls. While MVC does not maintain state information by using Viewstate.</li>
<li>WebForms support an event-driven programming style that is like Windows applications and is abstracted from the user. The State management is made transparent by using sessions, Viewstate etc… In the process, the HTML output is not clean making it difficult to manage later. The ViewState also increases your page size. In ASP.NET MVC, the output is clean and you have full control over the rendered HTML. The orientation is towards building standard compliant pages and provides full control over the behavior of an application.</li>
<li>Deep understanding of HTML, CSS and JavaScript is not required to a large extent since the WebForm model abstracts a lot of these details and provides automatic plumbing. While abstracting details to provide ease of use, sometimes a solution is overcomplicated, than it needs to be. In MVC, A thorough understanding of how HTML, CSS and JavaScript work together is required. The advantage is you can do a lot of jQuery and AJAX stuff in an efficient and simple manner than you would do in an ASP.NET application.</li>
<li>WebForms can drastically reduce time while building up intranet and internet applications that use a lot of controls (drag and drop model). Although this is true for development, a lot of time is spent later to code around limitations. In MVC, You lose the ‘drag and drop’ quick model of building your web applications. The focus is on control over the application behavior and test-driven development. The model is extensible and you do not have to spend time working around limitations.</li>
<li>Relatively simple to learn and pickup. Works very well for developers who initially have trouble with the HTTP/HTML model and are coming from a similar WinForms oriented event model. In MVC, There is a learning curve to understand the why, when and how of ASP.NET MVC.</li>
<li>Lesser amount of code is required to build Webapps since a lot of components are integrated and provided out of the box. You can also use a lot of data controls provided out of the box that rely on ViewState. In MVC, since the application tasks are separated into different components, amount of code required is more. Since ASP.NET MVC does not use ViewState, you cannot use Data controls like GridView, Repeater.</li>
<li>Webforms works very well for small teams where focus is on rapid application development. MVC works well for large projects where focus in on testability and maintainability.</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jenifertrinh.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jenifertrinh.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jenifertrinh.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jenifertrinh.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jenifertrinh.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jenifertrinh.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jenifertrinh.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jenifertrinh.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jenifertrinh.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jenifertrinh.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jenifertrinh.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jenifertrinh.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jenifertrinh.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jenifertrinh.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jenifertrinh.wordpress.com&amp;blog=9442160&amp;post=19&amp;subd=jenifertrinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jenifertrinh.wordpress.com/2009/09/11/what-are-the-key-difference-between-asp-net-webforms-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5691e68acc57a4b0e5ba81afca2d6378?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jenifertrinh</media:title>
		</media:content>
	</item>
		<item>
		<title>Scripting ASP.NET MVC Views Stored In The Database</title>
		<link>http://jenifertrinh.wordpress.com/2009/09/11/scripting-asp-net-mvc-views-stored-in-the-database/</link>
		<comments>http://jenifertrinh.wordpress.com/2009/09/11/scripting-asp-net-mvc-views-stored-in-the-database/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 23:32:28 +0000</pubDate>
		<dc:creator>jenifertrinh</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://jenifertrinh.wordpress.com/?p=11</guid>
		<description><![CDATA[Say you’re building a web application and you want, against your better judgment perhaps, to allow end users to easily customize the look and feel – a common scenario within a blog engine or any hosted application. With ASP.NET, view code tends to be some complex declarative markup stuck in a file on disk which [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jenifertrinh.wordpress.com&amp;blog=9442160&amp;post=11&amp;subd=jenifertrinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div class="entry">
<h1><span style="font-weight:normal;font-size:13px;">Say you’re building a web application and you want, against your better judgment perhaps, to allow end users to easily customize the look and feel – a common scenario within a blog engine or any hosted application.</span></h1>
<p>With ASP.NET, view code tends to be some complex declarative markup stuck in a file on disk which gets compiled by ASP.NET into an assembly. Most system administrators would first pluck out their own toenail rather than allow an end user permission to modify such files.</p>
<p>It’s possible to store such files in the database and use a <code>VirtualPathProvider</code> to load them, but that requires your application (and thus their views) to run in full trust. Is there a way you could safely store such views in the database in an application running in medium trust where the code in the view is approachable?</p>
<p><a rel="lightbox" href="http://haacked.com/images/haacked_com/WindowsLiveWriter/HostingASP.NETMVCViewsInTheDatabase_134EA/fun-scripting_2.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;margin:0 10px 0 0;" src="http://haacked.com/images/haacked_com/WindowsLiveWriter/HostingASP.NETMVCViewsInTheDatabase_134EA/fun-scripting_thumb.jpg" border="0" alt="" width="244" height="180" align="left" /></a> At the ALT.NET conference a little while back, <a title="Jimmy Schementi" rel="friend met co-worker" href="http://blog.jimmy.schementi.com/">Jimmy Schementi</a> and <a title="John Lam" rel="friend met co-worker" href="http://www.iunknown.com/">John Lam</a> <a title="ALT.NET Seattle Day 3" href="http://haacked.com/archive/2009/03/01/altnetseattle-day-three.aspx">gave a talk</a> about the pattern of hosting a scripting language within a larger application. For example, many modern 3-D Games have their high performance core engine written in C++ and Assembly. However, these games often use a scripting language, such as <a title="Lua programming language" href="http://www.lua.org/">Lua</a>, to write the scripts for the behaviors of characters and objects.</p>
<p>An example that might be more familiar to more people is the use of VBA to write macros for Excel. In both of these cases, the larger application hosts a scripting environment that allow end users to customize the application using a simpler lighter weight language than the one the core app is written in.</p>
<p>A long while back, I wrote a blog post about <a title="Defining Views in IronRuby" href="http://haacked.com/archive/2008/04/22/defining-asp.net-mvc-routes-and-views-in-ironruby.aspx">defining ASP.NET MVC Views in IronRuby</a> followed by a full <a title="IronRuby ASP.NET MVC" href="http://haacked.com/archive/2009/02/17/aspnetmvc-ironruby-with-filters.aspx">IronRuby ASP.NET MVC stack</a>. While there was some passionate interest by a few, in general, I was met with the thunderous sound of crickets. Why the huge lack of interest? Probably because I didn’t really sell the benefit and the explain the pain it solves. I’m sure many of you were asking, <em>Why bother? What’s in it for me?</em></p>
<p>After thinking about it some more, I realized that my prototypes appeared to suggest that if you want to take advantage of IronRuby, you would need to make some sort of wholesale switch to a new foreign language, not something to be undertaken lightly.</p>
<p>This is why I really like Jimmy and John’s recent efforts to focus on showing the benefits of hosting the DLR for scripting scenarios like the ones mentioned above. It makes total sense to me when I look at it in this perspective. The way I see it, most developers spend a huge bulk of their time in a single core language, typically their “language of choice”. For me, I spend the bulk of my time writing C# code.</p>
<p>However, I don’t think twice about the fact that I also write tons of JavaScript when I do web development, and I’ll write the occasional VB code when I need a new Macro for Visual Studio or Excel. I also write SQL when I need to. I’m happy to pick up and use a new language when it will enable me to do the job at hand more efficiently and naturally than C# does. I imagine many developers feel this way. The occasional use of a scripting languages is fine when it gets the job done and I can still spend most of my time in my favorite language.</p>
<p>So I started thinking about how that might work in a web application. What if you could write all your business logic and controller logic in your language of choice, but have your views written in a light weight scripting language. If my web application were to host a scripting engine, I could actually store the code in any medium I want, such as the database. Having them in the database makes it very easy for end users to modify it since it wouldn’t require file upload permissions into the web root.</p>
<p>This is where hosting the DLR is a nice fit. I put together a proof of concept for these ideas. This is just a prototype intended to show how such a workflow might work. In this prototype, you go about creating your models and controllers the way you normally would.</p>
<p>For example, here’s a controller that returns some structured data to the view in the form of an anonymous type.</p>
<div class="dropshadow code">
<div class="innerbox">
<pre class="csharpcode"><span class="kwrd">public</span> ActionResult FunWithScripting()
{
var someData = <span class="kwrd">new</span> {
salutation = <span class="str">"Are you having fun with scripting yet?"</span>,
theDate = DateTime.Now,
numbers = <span class="kwrd">new</span> <span class="kwrd">int</span>[] { 1, 2, 3, 4 }
};
<span class="kwrd">return</span> View(someData);
}</pre>
</div>
</div>
<p class="clear">Once you write your controller, but before you create your view, you compile the app and then go visit the URL.<img style="display:block;float:none;margin-left:auto;margin-right:auto;border-width:0;" title="View does not exist view" src="http://haacked.com/images/haacked_com/WindowsLiveWriter/HostingASP.NETMVCViewsInTheDatabase_134EA/view-does-not-exist_11.png" border="0" alt="View does not exist view" width="549" height="428" /></p>
<p>We haven’t created the view yet, so let’s follow the instructions and login. Afterwards, we this:</p>
<p><img style="display:block;float:none;margin-left:auto;margin-right:auto;border-width:0;" title="view editor" src="http://haacked.com/images/haacked_com/WindowsLiveWriter/HostingASP.NETMVCViewsInTheDatabase_134EA/view-editor_3.png" border="0" alt="view editor" width="553" height="924" /></p>
<p>Since the view doesn’t exist, I hooked in and provided a temporary view for the controller action which contains a view editor. Notice that at the bottom of the screen, you can see the current property names and values being passed to the view. For example, there’s an enumeration of integers as one property, so I was able to use the Ruby <code>each</code> method to print them out in the view.</p>
<p>The sweet little browser based source code editor is named <a title="Edit Area" href="http://www.cdolivet.com/index.php?page=editArea&amp;sess=d7189c4b90423ed1b1aff26ec520caba">Edit Area created by Christophe Dolivet</a>. Unfortunately, at the time I write this, it doesn’t yet have support for ERB style syntax highlighting schemes. That’s why the &lt;% and %&gt; aren’t highlighted in yellow.</p>
<p>When I click <em>Create View</em>, I get taken back to the request for the same action, but now I can see the view I just created (click to enlarge).</p>
<p><a rel="lightbox" href="http://haacked.com/images/haacked_com/WindowsLiveWriter/HostingASP.NETMVCViewsInTheDatabase_134EA/fun-with-scripting-view_2.png"><img style="display:block;float:none;margin-left:auto;margin-right:auto;border-width:0;" title="Fun with scripting view" src="http://haacked.com/images/haacked_com/WindowsLiveWriter/HostingASP.NETMVCViewsInTheDatabase_134EA/fun-with-scripting-view_thumb.png" border="0" alt="Fun with scripting view" width="517" height="478" /></a></p>
<p>In the future, I should be able to host C# views in this way. Mono already has a tool for dynamically compiling C# code passed in as a string which I could try and incorporate.</p>
<p>I’m seriously thinking of making this the approach for building skins in a future version of Subtext. That would make skin installation drop dead simple and not require any file directory access. Let me know if you make use of this technique in your applications.</p>
<p>If you try and run this prototype, please note that there are some quirky caching issues with editing existing views in the prototype. It’ll seem like your view is not being edited, but it’s a result of how views are being cached. It might take a bit of time before your edits show up. I’m sure there are other bugs I’m still in the process of fixing. But for the most part, the general principle is sound.</p>
<p>You can <strong><a title="IronRuby Views in Db" href="http://haacked.com/code/IronRubyViews-In-Db.zip">download the prototype here</a></strong>.</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jenifertrinh.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jenifertrinh.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jenifertrinh.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jenifertrinh.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jenifertrinh.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jenifertrinh.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jenifertrinh.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jenifertrinh.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jenifertrinh.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jenifertrinh.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jenifertrinh.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jenifertrinh.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jenifertrinh.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jenifertrinh.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jenifertrinh.wordpress.com&amp;blog=9442160&amp;post=11&amp;subd=jenifertrinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jenifertrinh.wordpress.com/2009/09/11/scripting-asp-net-mvc-views-stored-in-the-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5691e68acc57a4b0e5ba81afca2d6378?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jenifertrinh</media:title>
		</media:content>

		<media:content url="http://haacked.com/images/haacked_com/WindowsLiveWriter/HostingASP.NETMVCViewsInTheDatabase_134EA/fun-scripting_thumb.jpg" medium="image" />

		<media:content url="http://haacked.com/images/haacked_com/WindowsLiveWriter/HostingASP.NETMVCViewsInTheDatabase_134EA/view-does-not-exist_11.png" medium="image">
			<media:title type="html">View does not exist view</media:title>
		</media:content>

		<media:content url="http://haacked.com/images/haacked_com/WindowsLiveWriter/HostingASP.NETMVCViewsInTheDatabase_134EA/view-editor_3.png" medium="image">
			<media:title type="html">view editor</media:title>
		</media:content>

		<media:content url="http://haacked.com/images/haacked_com/WindowsLiveWriter/HostingASP.NETMVCViewsInTheDatabase_134EA/fun-with-scripting-view_thumb.png" medium="image">
			<media:title type="html">Fun with scripting view</media:title>
		</media:content>
	</item>
		<item>
		<title>Bin Deploying ASP.NET MVC</title>
		<link>http://jenifertrinh.wordpress.com/2009/09/11/bin-deploying-asp-net-mvc/</link>
		<comments>http://jenifertrinh.wordpress.com/2009/09/11/bin-deploying-asp-net-mvc/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 23:17:28 +0000</pubDate>
		<dc:creator>jenifertrinh</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://jenifertrinh.wordpress.com/?p=9</guid>
		<description><![CDATA[With the release of ASP.NET MVC Beta, the assemblies distributed with ASP.NET MVC are automatically installed into the GAC. System.Web.Mvc System.Web.Routing System.Web.Abstractions While developing an application locally, this isn’t a problem. But when you are ready to deploy your application to a hosting provider, this might well be a problem if the hoster does not [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jenifertrinh.wordpress.com&amp;blog=9442160&amp;post=9&amp;subd=jenifertrinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>With the release of <a title="ASP.NET MVC Website" href="http://asp.net/mvc">ASP.NET MVC</a> Beta, the assemblies distributed with ASP.NET MVC are automatically installed into the GAC.</p>
<ul>
<li>System.Web.Mvc </li>
<li>System.Web.Routing </li>
<li>System.Web.Abstractions </li>
</ul>
<p>While developing an application locally, this isn’t a problem. But when you are ready to deploy your application to a hosting provider, this might well be a problem if the hoster does not have the ASP.NET MVC assemblies installed in the GAC.</p>
<p>Fortunately, ASP.NET MVC is still bin-deployable. If your hosting provider has ASP.NET 3.5 SP1 installed, then you’ll only need to include the MVC DLL. If your hosting provider is still on ASP.NET 3.5, then you’ll need to deploy all three. It turns out that it’s really easy to do so.</p>
<p>Also, ASP.NET MVC <strong>runs in Medium Trust</strong>, so it should work with most hosting providers’ Medium Trust policies. It’s always possible that a hosting provider customizes their Medium Trust policy to be draconian.</p>
<p>What I like to do is use the <strong>Publish</strong> feature of Visual Studio to publish to a local directory and then upload the files to my hosting provider. If your hosting provider supports FTP, you can often skip this intermediate step and publish directly to the FTP site.</p>
<p>The first thing I do in preparation is to go to my MVC web application project and expand the References node in the project tree. Select the aforementioned three assemblies and in the <strong>Properties</strong> dialog, set <strong>Copy Local</strong> to <strong>True</strong>.</p>
<p><img style="display:inline;border-width:0;" title="copy-local-true_3" border="0" alt="copy-local-true_3" src="http://haacked.com/images/haacked_com/WindowsLiveWriter/BinDeployingASP.NETMVC_F744/copy-local-true_3_3.png" width="522" height="800" />  </p>
<p>Now just right click on your application and select <strong>Publish</strong>.</p>
<p> <img style="display:inline;border-width:0;" title="publish-project_3" border="0" alt="publish-project_3" src="http://haacked.com/images/haacked_com/WindowsLiveWriter/BinDeployingASP.NETMVC_F744/publish-project_3_3.png" width="492" height="853" /></p>
<p>This brings up the following <strong>Publish</strong> wizard.</p>
<p><img style="display:inline;border-width:0;" title="Publish-Web" border="0" alt="Publish-Web" src="http://haacked.com/images/haacked_com/WindowsLiveWriter/BinDeployingASP.NETMVC_F744/Publish-Web_3.png" width="590" height="442" /></p>
<p>Notice that in this example, I selected a local directory. When I hit <strong>Publish</strong>, all the files needed to deploy my app are available in the directory I chose, including the assemblies that were in the GAC.</p>
<p><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="bin-assemblies" border="0" alt="bin-assemblies" src="http://haacked.com/images/haacked_com/WindowsLiveWriter/BinDeployingASP.NETMVC_F744/bin-assemblies_3.png" width="582" height="528" /> </p>
<p>Now I am ready to XCOPY the application to my host, but before I do that, I really should test the application as a bin deployed app to be on the safe side.</p>
<p>Ideally, I would deploy this to some staging server, or a virtual machine that does not have ASP.NET MVC installed. Otherwise, I’m forced to uninstall ASP.NET MVC on the current machine and then test the application.</p>
<p>You might be wondering, as I did, why I can’t just use <code>gacutil</code> to temporarily unregister the assembly, test the app, then use it again to register the assembly. Because it was installed using an MSI, Windows won’t let you unregister it. Here’s a command prompt window that shows what I got when I tried.</p>
<p><img style="display:inline;border-width:0;" title="gacutil-mvc" border="0" alt="gacutil-mvc" src="http://haacked.com/images/haacked_com/WindowsLiveWriter/BinDeployingASP.NETMVC_F744/gacutil-mvc_3.png" width="549" height="372" /> </p>
<p>Notice that it says that “assembly is required by one or more applications”. In general, there shouldn’t be any difference between running your application with MVC gac’d and it ungac’d. But I wouldn’t trust me saying this, I’d test it out to be sure.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jenifertrinh.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jenifertrinh.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jenifertrinh.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jenifertrinh.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jenifertrinh.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jenifertrinh.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jenifertrinh.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jenifertrinh.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jenifertrinh.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jenifertrinh.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jenifertrinh.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jenifertrinh.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jenifertrinh.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jenifertrinh.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jenifertrinh.wordpress.com&amp;blog=9442160&amp;post=9&amp;subd=jenifertrinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jenifertrinh.wordpress.com/2009/09/11/bin-deploying-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5691e68acc57a4b0e5ba81afca2d6378?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jenifertrinh</media:title>
		</media:content>

		<media:content url="http://haacked.com/images/haacked_com/WindowsLiveWriter/BinDeployingASP.NETMVC_F744/copy-local-true_3_3.png" medium="image">
			<media:title type="html">copy-local-true_3</media:title>
		</media:content>

		<media:content url="http://haacked.com/images/haacked_com/WindowsLiveWriter/BinDeployingASP.NETMVC_F744/publish-project_3_3.png" medium="image">
			<media:title type="html">publish-project_3</media:title>
		</media:content>

		<media:content url="http://haacked.com/images/haacked_com/WindowsLiveWriter/BinDeployingASP.NETMVC_F744/Publish-Web_3.png" medium="image">
			<media:title type="html">Publish-Web</media:title>
		</media:content>

		<media:content url="http://haacked.com/images/haacked_com/WindowsLiveWriter/BinDeployingASP.NETMVC_F744/bin-assemblies_3.png" medium="image">
			<media:title type="html">bin-assemblies</media:title>
		</media:content>

		<media:content url="http://haacked.com/images/haacked_com/WindowsLiveWriter/BinDeployingASP.NETMVC_F744/gacutil-mvc_3.png" medium="image">
			<media:title type="html">gacutil-mvc</media:title>
		</media:content>
	</item>
		<item>
		<title>Attributes and ASP.NET MVC</title>
		<link>http://jenifertrinh.wordpress.com/2009/09/11/attributes-and-asp-net-mvc/</link>
		<comments>http://jenifertrinh.wordpress.com/2009/09/11/attributes-and-asp-net-mvc/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 23:10:37 +0000</pubDate>
		<dc:creator>jenifertrinh</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://jenifertrinh.wordpress.com/?p=6</guid>
		<description><![CDATA[Anyone who wants to learn about ASP.NET MVC will quickly discover that MVC makes extensive use of a relatively new feature of .NET called attributes. Many programmers who are new to ASP.NET MVC may also be new to the use of attributes. This article covers the basic concepts of attributes and their use in ASP.NET [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jenifertrinh.wordpress.com&amp;blog=9442160&amp;post=6&amp;subd=jenifertrinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div class="storycontent">
<div class='snap_preview'>
<ol>Anyone who wants to learn about ASP.NET MVC will quickly discover that MVC makes extensive use of a relatively new feature of .NET called attributes. Many programmers who are new to ASP.NET MVC may also be new to the use of attributes. This article covers the basic concepts of attributes and their use in ASP.NET MVC.</ol>
<h3> What is an Attribute?</h3>
<ol>An attribute is a class that inherits from the abstract class <a href="http://msdn.microsoft.com/en-us/library/system.attribute.aspx">System.Attribute</a>. By convention, all attributes are given a class name that ends with the word &#8220;Attribute&#8221;. The .NET framework recognizes this convention and allows you to drop &#8220;Attribute&#8221; from the syntax for attaching the attribute. For example, to attach <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.authorizeattribute(VS.100).aspx">System.Web.Mvc.AuthorizeAttribute</a> to a controller&#8217;s action method, you would use the following syntax: </ol>
<ol><strong>C# example</strong></ol>
<ol>
<pre>[Authorize]
public ActionResult Index() { }</pre>
<p> <strong>Visual Basic example</strong></ol>
<pre>      &lt;Authorize()&gt; _
      Function Index() As ActionResult
      End Function</pre>
<h3> Attribute Parameters</h3>
<ol>An attribute can take a parameter that is either positional or named. A positional parameter corresponds to the parameters of the attribute&#8217;s public constructors. For example, <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.actionnameattribute(VS.100).aspx">System.Web.Mvc.ActionNameAttribute</a> has a constructor that takes a name parameter.<strong> </strong></ol>
<ol><strong>C# example</strong></ol>
<ol>
<pre>[ActionName("Start")]
public ActionResult Index() { }</pre>
<p> <strong>Visual Basic example</strong></ol>
<pre style="padding-left:60px;">&lt;ActionName("Start")&gt; _
Function Index() As ActionResult
End Function</pre>
<ol> A named parameter corresponds to a public property or public field of an attribute. For example, <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.outputcacheattribute(VS.100).aspx">System.Web.Mvc.OutputCacheAttribute</a> has several public properties (named parameters).<strong> </strong></ol>
<ol><strong>C# example</strong></ol>
<pre style="padding-left:30px;">[OutputCache(CacheProfile = "MyProfile", Duration = 10)]
public ActionResult Index() { }</pre>
<ol> <strong>Visual Basic example</strong></ol>
<pre style="padding-left:60px;">&lt;OutputCache(CacheProfile := "MyProfile", Duration := 10)&gt; _
Function Index() As ActionResult
EndFunction</pre>
<h3> Customizing Your Own Attribute</h3>
<ol>You can write your own attribute by creating a class that inherits either directly or indirectly from System.Attribute. ASP.NET MVC has several abstract attributes that you are intended to customize. For example, you must customize <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.actionfilterattribute(VS.100).aspx">System.Web.Mvc.ActionFilterAttribute</a> to implement an action filter. The following class implements a simple logging action filter: </ol>
<ol><strong>C# example</strong></ol>
<ol>
<pre>public class LoggingFilterAttribute : ActionFilterAttribute    {</pre>
</ol>
<pre>        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            filterContext.HttpContext.Trace.Write("(Logging Filter)Action Executing: " +
                filterContext.ActionDescriptor.ActionName);
             base.OnActionExecuting(filterContext);
        }
         public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (filterContext.Exception != null)
                filterContext.HttpContext.Trace.Write("(Logging Filter)Exception thrown");
             base.OnActionExecuted(filterContext);
        }
    }</pre>
<ol><strong> Visual Basic example</strong></ol>
<pre>    Public Class LoggingFilterAttribute
          Inherits ActionFilterAttribute
       Public Overrides Sub OnActionExecuting(ByVal filterContext As ActionExecutingContext)
           filterContext.HttpContext.Trace.Write("(Logging Filter)Action Executing: " + _
                filterContext.ActionDescriptor.ActionName)
           MyBase.OnActionExecuting(filterContext)
       End Sub
       Public Overrides Sub OnActionExecuted(ByVal filterContext As ActionExecutedContext)
            If Not filterContext.Exception Is Nothing Then
                filterContext.HttpContext.Trace.Write("(Logging Filter)Exception thrown")
            End If
           MyBase.OnActionExecuted(filterContext)
        End Sub
    End Class</pre>
<h3> ASP.NET MVC Attributes</h3>
<ul>The following list shows the attributes that are currently available to you as an ASP.NET MVC programmer. All of these attributes are in the <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc(VS.100).aspx">System.Web.Mvc</a> namespace.</ul>
<ul>
<li>AcceptViewAttribute</li>
<li>ActionFilterAttribute</li>
<li>ActionMethodSelectorAttribute</li>
<li>ActionNameAttribute</li>
<li>ActionNameSelectorAttribute</li>
<li>AuthorizeAttribute</li>
<li>BindAttribute</li>
<li>CustomModelBinderAttribute</li>
<li>FilterAttribute</li>
<li>HandleErrorAttribute</li>
<li>HiddenInputAttribute</li>
<li>HttpDeleteAttribute</li>
<li>HttpGetAttribute</li>
<li>HttpPostAttribute</li>
<li>HttpPutAttribute</li>
<li>ModelBinderAttribute</li>
<li>NonActionAttribute</li>
<li>OutputCacheAttribute</li>
<li>RequireHttpsAttribute</li>
<li>ValidateAntiForgeryTokenAttribute</li>
<li>ValidateInputAttribute</li>
</ul>
</div></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jenifertrinh.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jenifertrinh.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jenifertrinh.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jenifertrinh.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jenifertrinh.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jenifertrinh.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jenifertrinh.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jenifertrinh.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jenifertrinh.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jenifertrinh.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jenifertrinh.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jenifertrinh.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jenifertrinh.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jenifertrinh.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jenifertrinh.wordpress.com&amp;blog=9442160&amp;post=6&amp;subd=jenifertrinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jenifertrinh.wordpress.com/2009/09/11/attributes-and-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5691e68acc57a4b0e5ba81afca2d6378?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jenifertrinh</media:title>
		</media:content>
	</item>
		<item>
		<title>mô hình mvc trong asp.net</title>
		<link>http://jenifertrinh.wordpress.com/2009/09/11/mo-hinh-mvc-trong-asp-net/</link>
		<comments>http://jenifertrinh.wordpress.com/2009/09/11/mo-hinh-mvc-trong-asp-net/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 23:03:47 +0000</pubDate>
		<dc:creator>jenifertrinh</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://jenifertrinh.wordpress.com/?p=3</guid>
		<description><![CDATA[xin phép dịch lại một số bài blog của tác giả Scott Guthrie về ASP.NET MVC Framework  để giới thiệu về một công nghệ mới ra đời của ASP.NET. Bài 1:  ASP.NET MVC Framework Một hạn chế của framework ASP.NET từ trước đến nay là không hỗ trợ các lập trình viên sử dụng kiến [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jenifertrinh.wordpress.com&amp;blog=9442160&amp;post=3&amp;subd=jenifertrinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>xin phép dịch lại một số bài blog của tác giả Scott Guthrie về ASP.NET MVC Framework  để giới thiệu về một công nghệ mới ra đời của ASP.NET.</p>
<p><img src="http://dotnetslackers.com/images/articleimages/mvc.jpg" alt="" width="550" height="318" /></p>
<h2>Bài 1:  <a href="http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx">ASP.NET MVC Framework</a></h2>
<p>Một hạn chế của framework ASP.NET từ trước đến nay là không hỗ trợ các lập trình viên sử dụng kiến trúc MVC để phát triển các ứng dụng, và nhiều người vẫn đang mong chờ sự xuất hiện của kiến trúc lâu năm này trong bộ framework.</p>
<p>Tuần trước, tại hội nghị Alt.NET ở Austin, tôi đã có một bài thuyết minh về một framework MVC mới cho ASP.NET mà nhóm của chúng tôi đang thực hiện. Bạn có thể xem đoạn video về bài thuyết trình của tôi ở trang nhật ký của <a href="http://www.hanselman.com/blog/ScottGuMVCPresentationAndScottHaScreencastFromALTNETConference.aspx">Scott Hanselman</a>.</p>
<p>Chúng tôi sẽ phát hành bản preview của framework MVC ASP.NET cho mọi người vào cuối năm nay. Dự kiến chúng tôi sẽ cho ra đời bản chính thức và được hỗ trợ đầy đủ vào nửa đầu của năm 2009.</p>
<p><strong>Model View Controller (MVC) là gì ?</strong></p>
<table border="0">
<tbody>
<tr>
<td>MCV là tên một phương pháp chia nhỏ một ứng dụng thành ba thành phần để cài đặt, mỗi thành phần đóng một vai trò khác nhau và ảnh hưởng lẫn nhau, đó là models, views, và controllers.</p>
<ol>
<li>Models trong các ứng dụng dựa trên MVC là những thành phần có nhiệm vụ lưu trữ thông tin, trạng thái của các đối tượng, thông thường nó là một lớp được ánh xạ từ một bảng trong CSDL. Lấy ví dụ, chúng ta có lớp Product được sử dụng để mô tả dữ liệu từ bảng Products trong SQL, bao gồm ProductID, OrderDate&#8230;</li>
<li>Còn đối với Views, nó chính là các thành phần chịu trách nhiệm hiển thị các thông tin lên cho người dùng thông qua giao diện. Thông thường, các thông tin cần hiển thị được lấy từ thành phần Models. Ví dụ, đối tượng Product có một &#8220;Edit&#8221; view bao gồm các textboxes, các dropdowns và checkboxes để chỉnh sửa các thuộc tính của sản phẩm; có một &#8220;Display&#8221; view gồm 2 dòng, cột dòng là ProductID, dòng sau là OrderDate&#8230; để xem thông tin về sản phẩm.</li>
<li>Cuối cùng, Controllers trong các ứng dụng kiểu MVC chịu trách nhiệm xử lý các tác động về mặt giao diện, các thao tác đối với models, và cuối cùng là chọn một view thích hợp để hiển thị ra màn hình. Trong kiến trúc MVC, view chỉ có tác dụng hiển thị giao diện mà thôi, còn điều kiển dòng nhập xuất của người dùng vẫn do Controllers đảm trách.</li>
</ol>
<p><img src="http://www.slash7.com/images/mvc.png" alt="" width="408" height="381" /></td>
<td><img src="http://www.scottgu.com/blogposts/mvc/step1.jpg" alt="" width="262" height="574" /></td>
</tr>
</tbody>
</table>
<p>Một lợi điểm của phương pháp MVC là nó bắt buộc phải tạo ra một sự rành mạch trong liên kết giữa 3 thành phần models, views và controllers trong ứng dụng. Duy trì được mối quan hệ rành mạch rõ ràng này khiến việc kiểm tra ứng dụng trở nên dễ dàng hơn, đồng thời trách nhiệm của từng thành phần được định nghĩa rõ ràng và cả ba đều làm việc ăn ý với nhau.</p>
<p>Pattern MVC cũng cho phép thực hiện <a href="http://en.wikipedia.org/wiki/Test-driven_development">red/green test driven development (TDD)</a>, cài đặt các unit tests tự động, xác định và kiểm tra lại các yêu cầu trước khi bắt tay vào viết code.<br />
*** Test-Driven Development (TDD) is a software development technique consisting of short iterations where new test cases covering the desired improvement or new functionality are written first, then the production code necessary to pass the tests is implemented, and finally the software is refactored to accommodate changes.</p>
<p><strong>Một vài chi tiết mà tôi có thể hé lộ vào thời điểm hiện tại, đó là:</strong></p>
<p>- Cho phép sự chia tách rành mạch giữa các thành phần, mỗi thành phần đều có khả năng được test riêng biệt và mặc định hỗ trợ TDD. Tất cả các mối liên hệ chính yếu trong MVC đều có giao diện để hiển thị và đều có thể xây dựng thành các mô hình, và bao gồm interface-based IHttpRequest/IHttpResponse. Bạn có thể chạy unit test cho ứng dụng mà không phải chạy các Controllers trong ASP.NET process, điều này làm unit test chạy nhanh hơn. Bạn có thể sử dụng unit testing framework nào cũng được, kể cả NUnit, MBUnit, MS Test&#8230;</p>
<p>- Được thiết kế để có thể dễ mở rộng và tiện dụng, tất cả mọi thứ trong MVC framework đều có thể nhanh chóng được thay đổi, tùy chọn hóa. Ví dụ bạn có thể viết một View và sử dụng cho nhiều ứng dụng khác nhau, đây là tính pluggable.</p>
<p>- Bao gồm thành phần ánh xạ URL cho phép bạn xây dựng các ứng dụng thân thiện với bộ máy tìm kiếm và với người dùng. Lấy ví dụ tôi có thể ánh xạ URL /products/edit/4 là một trang cho phép chỉnh sửa thông tin về các sản phẩm, hoặc là /Blogs/scottgu/10-10-2007/SomeTopic/  để xem các thông tin.</p>
<p>- MVC framework hỗ trợ sử dụng các các tập tin .ASPX, .ASCX và .Master như là thành phần View, điều đó có nghĩa là bạn vẫn có thể sử dụng các tính năng của ASP.NET như master pages, &lt;%= %&gt; snippets, server controls, templates, data-binding, localization&#8230; Tuy nhiên nó không sử dụng mô hình post-back từ giao diện gửi đến server nữa, thay vào đó, bạn có thể chủ động đưa những post-back từ giao diện đó đến thẳng lớp Controller. Tóm lại, không còn viewstate hay là page lifecycle còn tồn tại trong mô hình MVC.</p>
<p>- Vẫn tiếp tục hỗ trợ các tính năng ASP.NET như là forms/windows authentication, URL authorization, membership/roles, output and data caching, session/profile state management, health monitoring, configuration system, the provider architecture&#8230;</p>
<p><strong>Tổng kết</strong></p>
<p>Nếu bạn đang tìm kiếm một phương pháp xây dựng các ứng dụng web theo hướng MVC, tôi nghĩ ASP.NET MVC Framework mới ra này sẽ là một lựa chọn tốt, rất rành mạch và dễ sử dụng. Nó cho phép bạn dễ dàng bảo trì sự phân tách giữa các thành phần trong ứng dụng, đồng thời cũng rất tốt trong công việc testing và TDD.</p>
<p>Tôi sẽ viết nhiều bài hướng dẫn hơn trong những tuần sắp đến để mô tả cách thức làm việc của MVC, để cho bạn có thể nhận ra những ưu điểm và thuận lợi khi sử dụng công nghệ này.</p>
<p>Hy vọng những điều tôi viết nãy giờ là có ích<br />
Scott</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jenifertrinh.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jenifertrinh.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jenifertrinh.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jenifertrinh.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jenifertrinh.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jenifertrinh.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jenifertrinh.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jenifertrinh.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jenifertrinh.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jenifertrinh.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jenifertrinh.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jenifertrinh.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jenifertrinh.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jenifertrinh.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jenifertrinh.wordpress.com&amp;blog=9442160&amp;post=3&amp;subd=jenifertrinh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jenifertrinh.wordpress.com/2009/09/11/mo-hinh-mvc-trong-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5691e68acc57a4b0e5ba81afca2d6378?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jenifertrinh</media:title>
		</media:content>

		<media:content url="http://dotnetslackers.com/images/articleimages/mvc.jpg" medium="image" />

		<media:content url="http://www.slash7.com/images/mvc.png" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/mvc/step1.jpg" medium="image" />
	</item>
	</channel>
</rss>
