<?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>Đào Hải Nam</title>
	<atom:link href="http://namdh.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://namdh.wordpress.com</link>
	<description>Luôn hạnh phúc vì vẫn còn nhiều ước mơ chưa đạt được</description>
	<lastBuildDate>Tue, 29 Dec 2009 03:45:05 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>vi</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='namdh.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/1c63ca6e5752589591e864bdbef5ce1a?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Đào Hải Nam</title>
		<link>http://namdh.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://namdh.wordpress.com/osd.xml" title="Đào Hải Nam" />
		<item>
		<title>Ảnh lễ trao giao giải Thử Thách Widget N97</title>
		<link>http://namdh.wordpress.com/2009/12/22/nokia-n97-widget/</link>
		<comments>http://namdh.wordpress.com/2009/12/22/nokia-n97-widget/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 07:22:27 +0000</pubDate>
		<dc:creator>namdh</dc:creator>
				<category><![CDATA[Không phân loại]]></category>

		<guid isPermaLink="false">http://namdh.wordpress.com/?p=1075</guid>
		<description><![CDATA[




       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1075&subd=namdh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><div id="attachment_1076" class="wp-caption alignnone" style="width: 510px"><a href="http://namdh.files.wordpress.com/2009/12/p1000069-small.png"><img class="size-full wp-image-1076" title="P1000069-small" src="http://namdh.files.wordpress.com/2009/12/p1000069-small.png?w=500&#038;h=375" alt="" width="500" height="375" /></a><p class="wp-caption-text">Buổi lễ tổ chức tại khách sạn Caravelle</p></div>
<p><a href="http://namdh.files.wordpress.com/2009/12/p1000070-small.png"><img class="alignnone size-full wp-image-1077" title="P1000070-small" src="http://namdh.files.wordpress.com/2009/12/p1000070-small.png?w=375&#038;h=500" alt="" width="375" height="500" /></a></p>
<p><a href="http://namdh.files.wordpress.com/2009/12/p1000072-small.png"><img class="alignnone size-full wp-image-1078" title="P1000072-small" src="http://namdh.files.wordpress.com/2009/12/p1000072-small.png?w=375&#038;h=500" alt="" width="375" height="500" /><a href="http://namdh.files.wordpress.com/2009/12/p1000074-small.png"></a></a></p>
<p><a href="http://namdh.files.wordpress.com/2009/12/p1000072-small.png"><a href="http://namdh.files.wordpress.com/2009/12/p1000074-small.png"><img class="alignnone size-full wp-image-1079" title="P1000074-small" src="http://namdh.files.wordpress.com/2009/12/p1000074-small.png?w=375&#038;h=500" alt="" width="375" height="500" /></a></a></p>
<p><a href="http://namdh.files.wordpress.com/2009/12/p1000075-small.png"><img class="alignnone size-full wp-image-1080" title="P1000075-small" src="http://namdh.files.wordpress.com/2009/12/p1000075-small.png?w=375&#038;h=500" alt="" width="375" height="500" /></a></p>
<div id="attachment_1081" class="wp-caption alignnone" style="width: 510px"><a href="http://namdh.files.wordpress.com/2009/12/slide.png"><img class="size-full wp-image-1081" title="slide" src="http://namdh.files.wordpress.com/2009/12/slide.png?w=500&#038;h=380" alt="" width="500" height="380" /></a><p class="wp-caption-text">Úi, tên ai kia???</p></div>
<p><a href="http://namdh.files.wordpress.com/2009/12/p1000089-small.png"><img class="alignnone size-full wp-image-1082" title="P1000089-small" src="http://namdh.files.wordpress.com/2009/12/p1000089-small.png?w=500&#038;h=375" alt="" width="500" height="375" /></a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/namdh.wordpress.com/1075/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/namdh.wordpress.com/1075/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/namdh.wordpress.com/1075/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/namdh.wordpress.com/1075/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/namdh.wordpress.com/1075/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/namdh.wordpress.com/1075/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/namdh.wordpress.com/1075/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/namdh.wordpress.com/1075/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/namdh.wordpress.com/1075/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/namdh.wordpress.com/1075/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1075&subd=namdh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://namdh.wordpress.com/2009/12/22/nokia-n97-widget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">namdh</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/12/p1000069-small.png" medium="image">
			<media:title type="html">P1000069-small</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/12/p1000070-small.png" medium="image">
			<media:title type="html">P1000070-small</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/12/p1000072-small.png" medium="image">
			<media:title type="html">P1000072-small</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/12/p1000074-small.png" medium="image">
			<media:title type="html">P1000074-small</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/12/p1000075-small.png" medium="image">
			<media:title type="html">P1000075-small</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/12/slide.png" medium="image">
			<media:title type="html">slide</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/12/p1000089-small.png" medium="image">
			<media:title type="html">P1000089-small</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio 2010 and .NET Framework 4 sẽ có thêm phiên bản RC</title>
		<link>http://namdh.wordpress.com/2009/12/22/visual-studio-2010-and-net-framework-4-s%e1%ba%bd-co-them-phien-b%e1%ba%a3n-rc/</link>
		<comments>http://namdh.wordpress.com/2009/12/22/visual-studio-2010-and-net-framework-4-s%e1%ba%bd-co-them-phien-b%e1%ba%a3n-rc/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 04:47:25 +0000</pubDate>
		<dc:creator>namdh</dc:creator>
				<category><![CDATA[Không phân loại]]></category>

		<guid isPermaLink="false">http://namdh.wordpress.com/?p=1073</guid>
		<description><![CDATA[Do một số cập nhật, đặc biệt liên quan đến vấn để hiệu năng, nhóm phát triển VS 2010 đã quyết định đưa ra thêm phiên bản RC (Release Candidate), phiên bản này sẽ được ra mắt vào khoảng tháng 2/2010.
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1073&subd=namdh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Do một số cập nhật, đặc biệt liên quan đến vấn để hiệu năng, nhóm phát triển VS 2010 đã quyết định đưa ra thêm phiên bản RC (Release Candidate), phiên bản này sẽ được ra mắt vào khoảng tháng 2/2010.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/namdh.wordpress.com/1073/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/namdh.wordpress.com/1073/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/namdh.wordpress.com/1073/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/namdh.wordpress.com/1073/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/namdh.wordpress.com/1073/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/namdh.wordpress.com/1073/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/namdh.wordpress.com/1073/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/namdh.wordpress.com/1073/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/namdh.wordpress.com/1073/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/namdh.wordpress.com/1073/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1073&subd=namdh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://namdh.wordpress.com/2009/12/22/visual-studio-2010-and-net-framework-4-s%e1%ba%bd-co-them-phien-b%e1%ba%a3n-rc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">namdh</media:title>
		</media:content>
	</item>
		<item>
		<title>Hướng dẫn dịch và chạy thử Chrome OS</title>
		<link>http://namdh.wordpress.com/2009/11/26/compiling-chrome-os/</link>
		<comments>http://namdh.wordpress.com/2009/11/26/compiling-chrome-os/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 15:01:31 +0000</pubDate>
		<dc:creator>namdh</dc:creator>
				<category><![CDATA[Hệ điều hành]]></category>
		<category><![CDATA[Không phân loại]]></category>
		<category><![CDATA[chrome os]]></category>

		<guid isPermaLink="false">http://namdh.wordpress.com/?p=1052</guid>
		<description><![CDATA[Sau đây là hướng dẫn dành cho các bạn muốn tự dịch thử một bản Chrome OS

1. Chuẩn bị
Để dịch được ChromiumOS, bạn sẽ cần một số thứ sau:
- Hệ điều hành Ubuntu: mong muốn của Google là bạn có thể dịch ChromiumOS trên bất kỳ hệ điều hành Linux mới nào, tuy nhiên tại [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1052&subd=namdh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Sau đây là hướng dẫn dành cho các bạn muốn tự dịch thử một bản Chrome OS</p>
<p><span id="more-1052"></span></p>
<p><strong>1. Chuẩn bị</strong></p>
<p>Để dịch được ChromiumOS, bạn sẽ cần một số thứ sau:</p>
<p>- Hệ điều hành Ubuntu: mong muốn của Google là bạn có thể dịch ChromiumOS trên bất kỳ hệ điều hành Linux mới nào, tuy nhiên tại thời điểm hiện tại thì bạn chỉ có thể dùng Ubuntu phiên bản tối thiểu 8.04, và khuyên dùng là Ubuntu 9.10 (tôi dùng Ubuntu 9.10).</p>
<p>- Đĩa trống: tốt nhất là nên chuẩn bị khoảng 10GB theo yêu cầu, thực tế cho thấy có thể ít hơn một chút cũng được.</p>
<p>- Tài khoản root: bạn sẽ cần tài khoản có quyển root để dùng khi dịch cũng như khi cập nhật các thư viện.</p>
<p>- Các thư viện cần thiết:</p>
<ul>
<li>Python &gt;= 2.4</li>
<li>Perl &gt;= 5.x</li>
<li>gcc/g++ &gt;= 4.2</li>
<li>g++-multilib &gt;=4.2</li>
<li>bison &gt;= 2.3</li>
<li>flex &gt;= 2.5.34</li>
<li>gperf &gt;= 3.0.4</li>
<li>pkg-config &gt;= 0.20</li>
<li>libnss3-dev &gt;= 3.12</li>
<li>libasound2-dev</li>
<li>libgconf2-dev</li>
<li>libglib2.0-dev</li>
<li>libgtk2.0-dev</li>
<li>libnspr4-0d &gt;= 4.7.1+1.9-0ubuntu0.8.04.5</li>
<li>libnspr4-dev &gt;= 4.7.1+1.9-0ubuntu0.8.04.5</li>
<li>msttcorefonts (Microsoft fonts)</li>
<li>freetype-dev</li>
<li>libcairo2-dev</li>
<li>libdbus-1-dev</li>
</ul>
<p>Tùy chọn:</p>
<ul>
<li>wdiff</li>
<li>lighttpd</li>
<li>php5-cgi</li>
<li>sun-java6-fonts (needed for Lucida)</li>
</ul>
<p>Bạn đừng lo khi nhìn danh sách trên, vì sẽ có công cụ để giúp bạn kiểm tra và cập nhật một cách tự động, nếu đã tải mã nguồn về, bạn có thể chạy ~/chromium/src/build/install-build-deps.sh (xem phần tải mã nguồn), không thì có thể chạy lệnh sau để cập nhật:</p>
<pre><span style="color:#339966;">$ sudo apt-get install subversion pkg-config python perl g++ g++-multilib \</span>
<span style="color:#339966;">bison flex gperf libnss3-dev libgtk2.0-dev libnspr4-0d libasound2-dev \</span>
<span style="color:#339966;">libnspr4-dev msttcorefonts libgconf2-dev libcairo2-dev libdbus-1-dev</span>
<a name="Ubuntu_Setup">
</a><a href="http://namdh.files.wordpress.com/2009/11/install_requirements.png"><img class="alignnone size-full wp-image-1053" title="install_requirements" src="http://namdh.files.wordpress.com/2009/11/install_requirements.png?w=720&#038;h=379" alt="" width="720" height="379" /></a></pre>
<p><a name="Ubuntu_Setup">Và chạy tiếp lệnh sau để cài các thành phần tùy chọn:</a></p>
<pre><a name="Ubuntu_Setup"></a>
<pre><span style="color:#339966;"><a name="Ubuntu_Setup">$ sudo apt-get install wdiff lighttpd php5-cgi sun-java6-fonts</a></span></pre>
<p><a href="http://namdh.files.wordpress.com/2009/11/install_optional_extras.png"><img class="alignnone size-full wp-image-1054" title="install_optional_extras" src="http://namdh.files.wordpress.com/2009/11/install_optional_extras.png?w=720&#038;h=379" alt="" width="720" height="379" /></a></pre>
<p><strong>2. Tải mã nguồn</strong></p>
<p>Bạn tải về mã nguồn từ địa chỉ <a href="http://build.chromium.org/buildbot/archives/chromiumos-0.4.22.8.tar.gz">http://build.chromium.org/buildbot/archives/chromiumos-0.4.22.8.tar.gz</a>, giải nén vào một thư mục tên chomiumos trong /usr/local/.</p>
<p>Còn một cách nữa là dùng Git để lấy mã nguồn trực tiếp từ repository của Google, tuy nhiên chỉ dùng cách này nếu bạn là nhà phát triển.</p>
<p>Bạn cũng có thể tải thêm mã nguồn trình duyệt Chrome để dịch chung với ChromiumOS, tuy nhiên tôi chọn cách tải bản dịch sẵn (<a href="http://build.chromium.org/buildbot/archives/chromium-chromiumos-r32516.zip">http://build.chromium.org/buildbot/archives/chromium-chromiumos-r32516.zip</a>) cho đỡ tốn thời gian.</p>
<p><strong>3. Dịch</strong></p>
<p>Nhớ rằng trong các bước kế tiếp, bạn vẫn đang ở chế độ non-root, nếu bạn thực hiện sudo thì sẽ bị lỗi trong một số script cũng như một số tranh chấp về permission.</p>
<p>- Tạo một soft link, điều này là không bắt buộc nhưng sẽ giúp bạn dễ dàng hơn trong các bước sau: <span style="color:#339966;"><code>ln -s /usr/local/chromiumos</code><code> ~/chromiumos</code></span>, sau bước này bạn sẽ thấy trong ~/chromiumos có các thư mục cần thiết như src và tools.</p>
<p>- Chuyển vào thư mục ~/chromiumos/src/scripts:</p>
<pre><span style="color:#339966;">cd ~/chromiumos/src/scripts</span></pre>
<p>- Tạo một local repository:</p>
<p><span style="color:#339966;"><code>./make_local_repo.sh</code></span></p>
<p>Chú ý là quá trình này khá tốn thời gian vì nó sẽ phải tải các file thư viện về máy, trên máy tôi quá trình này chạy mất hơn 1 giờ đồng hồ, sau khi chạy xong bạn sẽ thấy có thêm một thư mục có tên repo với kích thước khoảng 1,7GB.</p>
<p>- Tạo chroot:</p>
<pre><span style="color:#339966;"><code>./make_chroot.sh</code></span></pre>
<p>Sau bước này, bạn sẽ chuyển vào môi trường chroot (đầu dấu nhắc xuất hiện (chroot)), bước này cũng mất khoảng 10 phút.</p>
<p>- Nếu muốn tạo một account để đăng nhập (không cần mạng), bạn có thể chạy các lệnh sau:</p>
<pre><span style="color:#339966;"><code>cd ../platform/pam_google </code></span>
<span style="color:#339966;"><code>./enable_localaccount.sh <em>USERNAME</em></code></span></pre>
<p>Khi đó sẽ có một account tên USERNAME trên bản dịch.</p>
<p>- Nếu muốn sau này dùng lệnh sudo, bạn gõ lệnh sau và nhập vào password:</p>
<pre><span style="color:#339966;"><code>./set_shared_user_password.sh</code></span></pre>
<p>(Nếu không chạy lệnh này, password sudo sẽ được đặt là một chuỗi ngẫu nhiên)</p>
<p>- Dịch các gói:</p>
<pre><span style="color:#339966;"><code>./build_platform_packages.sh
 ./build_kernel.sh</code></span></pre>
<p>Bạn cũng có thể chạy tất cả các bước dịch bằng lệnh ./build_all.sh, lệnh này có thể chạy lâu hơn vì nó phải dịch và chạy thêm các gói test. Bước này cũng mất khoảng 30 phút.</p>
<p>- Tạo ảnh:</p>
<pre><span style="color:#339966;">./build_image.sh</span></pre>
<p>Nếu thành công, sau bước này bạn sẽ có các file cần thiết để chép vào USB hay tạo file ảnh VMWare.</p>
<p>Một thư mục mới sẽ được tạo trong <code>~/chromiumos/src/build/images</code>, tên thư mục được tạo ngẫu nhiên theo một cách quái dị nào đó <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> :</p>
<p><a href="http://namdh.files.wordpress.com/2009/11/file_list.png"><img class="alignnone size-full wp-image-1055" title="file_list" src="http://namdh.files.wordpress.com/2009/11/file_list.png?w=720&#038;h=351" alt="" width="720" height="351" /></a></p>
<p><strong>4. Tạo đĩa ảo</strong>:</p>
<p>Lệnh sau được dùng để tạo file ảnh cho VMware:</p>
<pre><span style="color:#339966;">./image_to_vmware.sh --from=~/chromiumos/src/build/images/SUBDIR \
</span>
--to=~/chromiumos/src/build/images/ide.vmdk</pre>
<p>Lệnh này sẽ tạo file có tên ide.vmdk chứa hệ điều hành ChromiumOS, trong lệnh trên, bạn thay SUBDIR bằng tên thư mục chứa ảnh hệ điều hành, trong ví dụ này là 999.99932909.165250-a1. Nhớ là chạy lệnh này ngoài chế độ chroot (mở cửa sổ Terminal mới).</p>
<p>Sau đây là kết quả <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> :</p>
<div id="attachment_1056" class="wp-caption alignnone" style="width: 730px"><a href="http://namdh.files.wordpress.com/2009/11/login.png"><img class="size-full wp-image-1056 " title="login" src="http://namdh.files.wordpress.com/2009/11/login.png?w=720&#038;h=540" alt="" width="720" height="540" /></a><p class="wp-caption-text">Màn hình đăng nhập, vì ở trên tôi chạy lệnh ./enable_localaccount.sh namdh nên ở đây tôi có thể đăng nhập bằng tài khoản này</p></div>
<div id="attachment_1056" class="wp-caption alignnone" style="width: 730px"></dt>
</dl>
</div>
<div class="mceTemp">
<dl class="wp-caption alignnone">
<dt class="wp-caption-dt"><a href="http://namdh.files.wordpress.com/2009/11/about_memory.png"><img class="size-full wp-image-1057" title="about_memory" src="http://namdh.files.wordpress.com/2009/11/about_memory.png?w=720&#038;h=540" alt="" width="720" height="540" /></a><p class="wp-caption-text">Xem bộ nhớ, có vẻ sử dụng rất ít</p></div>
<div id="attachment_1058" class="wp-caption alignnone" style="width: 730px"><a href="http://namdh.files.wordpress.com/2009/11/chromium_settings_basics.png"><img class="size-full wp-image-1058" title="chromium_settings_basics" src="http://namdh.files.wordpress.com/2009/11/chromium_settings_basics.png?w=720&#038;h=540" alt="" width="720" height="540" /></a><p class="wp-caption-text">Cấu hình trình duyệt Chrome</p></div>
<div id="attachment_1059" class="wp-caption alignnone" style="width: 730px"><a href="http://namdh.files.wordpress.com/2009/11/home.png"><img class="size-full wp-image-1059" title="home" src="http://namdh.files.wordpress.com/2009/11/home.png?w=720&#038;h=541" alt="" width="720" height="541" /></a><p class="wp-caption-text">Menu chính</p></div>
<div id="attachment_1060" class="wp-caption alignnone" style="width: 730px"><a href="http://namdh.files.wordpress.com/2009/11/support_flash.png"><img class="size-full wp-image-1060" title="support_flash" src="http://namdh.files.wordpress.com/2009/11/support_flash.png?w=720&#038;h=540" alt="" width="720" height="540" /></a><p class="wp-caption-text">Có sẵn khả năng hỗ trợ Flash</p></div>
<div id="attachment_1061" class="wp-caption alignnone" style="width: 730px"><a href="http://namdh.files.wordpress.com/2009/11/network_error.png"><img class="size-full wp-image-1061" title="network_error" src="http://namdh.files.wordpress.com/2009/11/network_error.png?w=720&#038;h=537" alt="" width="720" height="537" /></a><p class="wp-caption-text">Menu chính khi không có mạng <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p></div>
 Tagged: chrome os <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/namdh.wordpress.com/1052/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/namdh.wordpress.com/1052/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/namdh.wordpress.com/1052/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/namdh.wordpress.com/1052/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/namdh.wordpress.com/1052/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/namdh.wordpress.com/1052/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/namdh.wordpress.com/1052/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/namdh.wordpress.com/1052/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/namdh.wordpress.com/1052/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/namdh.wordpress.com/1052/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1052&subd=namdh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://namdh.wordpress.com/2009/11/26/compiling-chrome-os/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">namdh</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/11/install_requirements.png" medium="image">
			<media:title type="html">install_requirements</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/11/install_optional_extras.png" medium="image">
			<media:title type="html">install_optional_extras</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/11/file_list.png" medium="image">
			<media:title type="html">file_list</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/11/login.png" medium="image">
			<media:title type="html">login</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/11/about_memory.png" medium="image">
			<media:title type="html">about_memory</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/11/chromium_settings_basics.png" medium="image">
			<media:title type="html">chromium_settings_basics</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/11/home.png" medium="image">
			<media:title type="html">home</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/11/support_flash.png" medium="image">
			<media:title type="html">support_flash</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/11/network_error.png" medium="image">
			<media:title type="html">network_error</media:title>
		</media:content>
	</item>
		<item>
		<title>Những điều cần biết về Google Chrome OS</title>
		<link>http://namdh.wordpress.com/2009/11/21/google-chrome-os/</link>
		<comments>http://namdh.wordpress.com/2009/11/21/google-chrome-os/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 07:06:36 +0000</pubDate>
		<dc:creator>namdh</dc:creator>
				<category><![CDATA[Hệ điều hành]]></category>
		<category><![CDATA[chrome os]]></category>

		<guid isPermaLink="false">http://namdh.wordpress.com/?p=1040</guid>
		<description><![CDATA[Như chúng ta đã biết, Google vừa công bố dự án hệ điều hành Chrome OS, vậy chúng ta cùng tìm hiểu các đặc điểm của hệ điều hành này.
1. Trình duyệt Chrome sẽ là một phần của hệ điều hành:
Trình duyệt Chrome nay sẽ trở thành Shell của hệ điều hành, tương tự như [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1040&subd=namdh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Như chúng ta đã biết, Google vừa công bố dự án hệ điều hành Chrome OS, vậy chúng ta cùng tìm hiểu các đặc điểm của hệ điều hành này.</p>
<p><strong><span id="more-1040"></span>1. Trình duyệt Chrome sẽ là một phần của hệ điều hành</strong>:</p>
<p>Trình duyệt Chrome nay sẽ trở thành Shell của hệ điều hành, tương tự như Explorer của Windows, điều này có nghĩa là nó sẽ cung cấp giao diện chính cho người dùng tương tác với máy tính. Và bởi vì Google thiết kế ra Chrome OS cho người chuyên lướt web nên điều này cũng dễ hiểu, bạn bật máy tính, vào facebook, lướt web, đọc tin tức, duyệt mail, thậm chí soạn thảo văn bản hay mở bảng tính, tất cả đều qua web nhờ sự trợ giúp của trình duyệt Chrome.</p>
<p>Tuy nhiên những người yêu thích Firefox có lẽ cũng vẫn an tâm vì theo thiết kế thì việc sử dụng trình duyệt Chrome OS là không bắt buộc, nó có thể được thay thế một trình duyệt Linux x86 khác, tất nhiên từ giờ cho đến khi ra mắt, các nhà phát triển FireFox cũng phải tạo ra một phiên bản Chrome OS &#8211; enabled.</p>
<p><strong>2. Các ứng dụng trên Chrome đều sẽ là ứng dụng Web</strong>:</p>
<p>Sẽ không có bất kỳ chương trình truyền thống nào được dùng trên Chrome OS, bạn sẽ bỏ đi mọi ứng dụng quen thuộc chạy trên desktop như trước đây. Chỉ có một số rất ít ứng dụng được cài sẵn chạy trực tiếp ngay trên máy tính, nhưng nó cũng sẽ mang giao diện web, như các trò chơi đơn giản, trình nghe nhạc&#8230;</p>
<p><strong>3. Dữ liệu được chủ yếu lưu trên các &#8220;đám mây&#8221;</strong>:</p>
<p>Dữ liệu của bạn sẽ được lưu trữ trên các máy chủ ở &#8220;đâu đó&#8221;, điều này giúp bạn có thể truy cập từ bất kỳ máy tính nào, bạn không cần phải sao lưu, nhưng để người dùng quen với việc này cũng không dễ, vì những dữ liệu quan trọng có thể sẽ là cả tài sản cuản bạn, việc đưa nó lên một máy chủ nào đó ngoài tầm kiểm soát đôi khi không phải là một ý kiến hay.</p>
<p>Trước đây Larry Elisson, chủ tịch Oracle, cũng từng cổ súy cho mô hình này, với mong muốn xô đổ tượng đài Windows, nhưng đã thất bại. Có thể giờ đây thời thế đã thay đổi, Internet và băng thông rộng đã phổ biến hơn, người dùng cũng dành nhiều thời gian làm việc trên web hơn, các ứng dụng Internet cũng phong phú hơn nhiều, bản thân Google cũng chẳng phải tay vừa, vậy nên biết đâu cuộc chiến này sẽ có một kết cục khác <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p><strong>4. Sẽ chưa có Chrome OS ngay cho người dùng</strong>:</p>
<p>Theo kế hoạch, 10/2010 Chrome OS mới bắt đầu được phát hành, tuy nhiên phiên bản này có lẽ chủ yếu được cài sẵn trong một số dòng máy, Google đã bắt tay với một số nhà cung cấp máy tính lớn để xây dựng các hệ thống chạy hệ điều hành này, cũng như các phiên bản cho các dòng netbook đã có.</p>
<p>Tuy nhiên hiện tại bạn đã có thể tải về mã nguồn và build nó: http://www.chromium.org/chromium-os/building-chromium-os. Tuy nhiên từ giờ cho tới lúc phát hành thực sự, có lẽ sẽ còn có nhiều thay đổi.</p>
<p><strong>5. Ổ cứng đối với máy tính chạy Chrome OS không còn quan trọng</strong>:</p>
<p>Ổ cứng trước đây được dùng để chứa dữ liệu và các chương trình, nhưng nay vì tất cả đã được đưa lên web, do vậy nó chỉ còn là nơi chứa hệ điều hành, bao gồm cả trình duyệt Chrome OS. Dung lượng mã nguồn hệ điều hành sau khi nén lại khoảng 232MB, và trình duyệt là 803MB (không rõ tại sao to như vậy), có lẽ bản cài đặt sẽ thừa sức nằm gọn trong một ổ cứng 4GB tính luôn phân vùng swap, thậm chí có thể chỉ trong 2GB. Dung lượng nhỏ kết hợp với việc chủ yếu chỉ đọc, có lẽ các netbook được thiết kế riêng cho Chrome OS chỉ cần trang bị các ổ đĩa dạng flash giá rẻ, chi phí, điện năng tiêu thụ và giá thành do vậy sẽ được giảm đáng kể.</p>
<p><strong>6. Khả năng tự sửa lỗi</strong>:</p>
<p>Theo thiết kế, khi khởi động, Chrome OS sẽ tự kiểm tra các thành phần của nó, nếu thấy có gì bị thay đổi, nó sẽ tự động kết nối và tải về lại, rồi khởi động lại với phiên bản mới lấy về. Như vậy, các nguy cơ về việc thay đổi hệ thống sẽ bị loại trừ, cộng với việc dữ liệu được lưu từ xa, các ứng dụng cũng chạy từ xa, Chrome OS sẽ trở thành hệ điều hành an toàn nhất.</p>
<p><strong>7. Bạn luôn phải online nếu muốn dùng Chrome OS</strong>:</p>
<p>Như vậy, rõ ràng để dùng được hệ điều hành của Google, bạn không thể ở chế độ offline, vì sẽ không thể truy cập được các ứng dụng và dữ liệu. Không rõ Google Gear có thể giúp ích gì không, tuy nhiên nếu có thì vẫn luôn có những hạn chế của nó. Thêm nữa, hiện tại bạn cũng sẽ không thể dùng Wifi khi đang di chuyển, do vậy ở Việt Nam, cho đến khi nào 3G còn chưa phủ sóng rộng rãi, và &#8220;chưa rẻ&#8221;, thì một chiếc máy cài ChromeOS có lẽ vẫn chỉ là một chiếc máy &#8220;di động cố định&#8221; <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Kết luận</strong></p>
<p>Rõ ràng, việc tạo ra một hệ điều hành cho máy tính cá nhân cũng đồng nghĩa với việc cạnh tranh trực tiếp với Microsoft. Tuy nhiên, qua những gì Google đang làm, ta có thể thấy phân khúc họ hướng đến chỉ là các hệ thống giá rẻ, yêu cầu người dùng đơn giản. Lợi thế khi chọn phân khúc này là người dùng không muốn chi nhiều tiền cho máy tính và phần mềm, số lượng phần cứng cần hỗ trợ ít, các ứng dụng web cũng đã có sẵn khá nhiều, điện toán đám mây đang là mốt&#8230; Nhưng thực tế, việc tranh giành thị phần với MS không hề đơn giản, Apple, Linux&#8230; đã làm điều đó từ nhiều năm nay, nhưng cũng chỉ lấy được một phần nhỏ trong miếng bánh.</p>
<p>Tuy nhiên, cùng với việc ra đời ngôn ngữ Go, chúng ta có thể thấy được tham vọng của Google trong việc thay đổi cách sử dụng Internet, họ muốn làm cho Internet trở thành một nền tảng, máy tính cá nhân chỉ còn là một phương tiện nhập liệu và hiển thị. Trình duyệt Chrome chạy trên ChromeOS, truy cập vào các ứng dụng trên các máy chủ của Google, tải về dữ liệu cũng từ các máy chủ của Google. Việc xử lý trên trình duyệt sẽ dùng Go, vốn được hỗ trợ bởi, thay cho Javascript, giúp cho khả năng tương tác với người dùng, khả năng tương tác với máy chủ tốt hơn.</p>
<p>Dù gì đi nữa, việc có nhiều công ty cùng tham gia sẽ giúp cho người dùng có nhiều lựa chọn hơn, giá thành cũng sẽ rẻ hơn.</p>
<p><em>&#8220;Chỉ có anh em lập trình là khổ, chưa học xong cái này nó đã ra các khác, thành ra các gì cũng biết nhưng lại chẳng đâu ra đâu, he he&#8221;</em></p>
<p>***************************************************************************************************************************</p>
<h2><strong><br />
</strong></h2>
<p><em><br />
</em></p>
 Tagged: chrome os <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/namdh.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/namdh.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/namdh.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/namdh.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/namdh.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/namdh.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/namdh.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/namdh.wordpress.com/1040/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/namdh.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/namdh.wordpress.com/1040/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1040&subd=namdh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://namdh.wordpress.com/2009/11/21/google-chrome-os/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">namdh</media:title>
		</media:content>
	</item>
		<item>
		<title>Những tính năng mới trong WPF 4</title>
		<link>http://namdh.wordpress.com/2009/11/03/whats-new-in-wpf-4/</link>
		<comments>http://namdh.wordpress.com/2009/11/03/whats-new-in-wpf-4/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 03:03:01 +0000</pubDate>
		<dc:creator>namdh</dc:creator>
				<category><![CDATA[Microsoft .NET]]></category>

		<guid isPermaLink="false">http://namdh.wordpress.com/?p=1033</guid>
		<description><![CDATA[
Cung cấp các control mới
Ba loại control mới được thêm vào WPF cho phép dễ dàng tạo ra các ứng dụng kinh doanh. Các control này cũng hầu như 100% tương thích với các phiên bản Silverlight. Điều này cho phép các nhà phát triển có thể dùng lại code và tạo ra các phiên [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1033&subd=namdh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><div>
<div><span style="text-decoration:underline;"><strong>Cung cấp các control mới</strong></span></div>
<div><a id="sectionToggle0"></a>Ba loại control mới được thêm vào WPF cho phép dễ dàng tạo ra các ứng dụng kinh doanh. Các control này cũng hầu như 100% tương thích với các phiên bản Silverlight. Điều này cho phép các nhà phát triển có thể dùng lại code và tạo ra các phiên bản client và web nhanh chóng. Các control này bao gồm:</p>
<ul>
<li><a id="ctl00_MTCS_main_ctl89_ctl00_ctl00" href="http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid%28VS.100%29.aspx">DataGrid</a></li>
<li><a id="ctl00_MTCS_main_ctl89_ctl00_ctl01" href="http://msdn.microsoft.com/en-us/library/system.windows.controls.calendar%28VS.100%29.aspx">Calendar</a></li>
<li><a id="ctl00_MTCS_main_ctl89_ctl00_ctl02" href="http://msdn.microsoft.com/en-us/library/system.windows.controls.datepicker%28VS.100%29.aspx">DatePicker</a></li>
</ul>
</div>
</div>
<p><a id="visual_state_manager"></a><span id="more-1033"></span></p>
<div>
<div><!-- ApplyClick with current id --><span style="text-decoration:underline;"><strong> Visual State Manager</strong></span></div>
<div><a id="sectionToggle1"></a>WPF cung cấp một sự hỗ trợ tốt hơn cho việc thay đổi trạng thái hiển thị trong một ControlTemplate. Lớp VisualStateManager cùng các lớp hỗ trợ đã được thêm vào cho phép các công cụ như Microsoft Expression Blend có thể dùng để định nghĩa cách hiển thị đối tượng căn cứ theo trạng thái hiển thị của nó. Ví dụ, bạn có thể định nghĩa cách hiển thị của một Button khi nó ở trang thái Pressed. Để có thêm thông tin về việc tạo một ControlTemplate dùng VisualStateManager đối với một control đã có, xem bài <a id="ctl00_MTCS_main_ctl90_ctl00_ctl05" href="http://msdn.microsoft.com/en-us/library/ee230084%28VS.100%29.aspx">Customizing the Appearance of an Existing Control by Creating a ControlTemplate</a>. Thông tin về cách tạo một control mới dùng VisualStateManager, xem bài <a id="ctl00_MTCS_main_ctl90_ctl00_ctl07" href="http://msdn.microsoft.com/en-us/library/ee330302%28VS.100%29.aspx">Creating a Control That Has a Customizable Appearance</a>.</div>
</div>
<div><img src="http://i.msdn.microsoft.com/Global/Images/clear.gif" alt="" /><span style="text-decoration:underline;"><strong>Touch and Manipulation</strong></span></div>
<div>
<div><a id="sectionToggle2"></a>Các thành phần trong WPF đã bắt đầu hỗ trợ nhập liệu bằng màn hình cảm ứng. Các lớp UIElement, UIElement3D và ContentElement cung cấp các sự kiện phát sinh khi người dùng chạm vàm một màn hình cảm ứng. Các sự kiện sau được định nghĩa trong UIElement và phản hồi lại các thao tác chạm vào màn hình, các sự kiện này cũng được định nghĩa trong UIElement3D và ContentElement.</p>
<ul>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl06" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.previewtouchdown%28VS.100%29.aspx">PreviewTouchDown</a></li>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl07" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.touchdown%28VS.100%29.aspx">TouchDown</a></li>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl08" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.previewtouchmove%28VS.100%29.aspx">PreviewTouchMove</a></li>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl09" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.touchmove%28VS.100%29.aspx">TouchMove</a></li>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl10" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.previewtouchup%28VS.100%29.aspx">PreviewTouchUp</a></li>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl11" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.touchup%28VS.100%29.aspx">TouchUp</a></li>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl12" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.gottouchcapture%28VS.100%29.aspx">GotTouchCapture</a></li>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl13" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.losttouchcapture%28VS.100%29.aspx">LostTouchCapture</a></li>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl14" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.touchenter%28VS.100%29.aspx">TouchEnter</a></li>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl15" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.touchleave%28VS.100%29.aspx">TouchLeave</a></li>
</ul>
<p>Ngoài các sự kiện, UIElement cũng hỗ trợ cho một số thao tác. Một thao tác sẽ được thông dịch thành phóng to/thu nhỏ, quay hoặc di chuyển đối tượng. Ví dụ một ứng dụng xem ảnh sẽ cho phép di chuyển, thay đổi hoặc xoay ảnh bằng cách chạm vào bức ảnh trên màn hình. Các sự kiện sau đã được thêm vào lớp UIElement:</p>
<ul>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl19" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.manipulationstarted%28VS.100%29.aspx">ManipulationStarted</a></li>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl20" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.manipulationdelta%28VS.100%29.aspx">ManipulationDelta</a></li>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl21" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.manipulationinertiastarting%28VS.100%29.aspx">ManipulationInertiaStarting</a></li>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl22" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.manipulationcompleted%28VS.100%29.aspx">ManipulationCompleted</a></li>
<li><a id="ctl00_MTCS_main_ctl91_ctl00_ctl23" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.manipulationboundaryfeedback%28VS.100%29.aspx">ManipulationBoundaryFeedback</a></li>
</ul>
<p>Để cho phép các thao tác này, đặt giá trị <a id="ctl00_MTCS_main_ctl91_ctl00_ctl24" href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.ismanipulationenabled%28VS.100%29.aspx">IsManipulationEnabled</a> thành true. Để có thêm thông tin về cảm ứng, xem <a id="ctl00_MTCS_main_ctl91_ctl00_ctl25" href="http://msdn.microsoft.com/en-us/library/ee649090%28VS.100%29.aspx">Walkthrough: Creating Your First Touch Application</a>.</p>
</div>
</div>
<div>
<div><!-- ApplyClick with current id --></div>
<div><span style="text-decoration:underline;"><strong>Đồ họa và hoạt hình</strong></span></div>
<div><a id="sectionToggle3"></a>Một số thay đổi liên quan đến đồ họa và hoạt hình:</p>
<ul>
<li>Layout RoundingKhi một cạnh của đối tượng rơi vào chính giữa 2 pixel, hệ thống đồ họa của WPF sẽ dùng một số cách để giải quyết, như làm mờ hay trong mờ. Các phiên bản trước của WPF bao gồm khả năng pixel snapping để giúp xử lý trường hợp này (Dùng SnapsToDevicePixels). Silverlight 2 giời thiệu một tính năng mới là layout rounding, làmột cách khác để di chuyển các element sao cho các cạnh rơi đúng vào các điểm. WPF hiện đã hỗ trợ layout rounding với thuộc tính UseLayoutRounding.</li>
</ul>
<ul>
<li>Cached CompositionBằng cách dùng các lớp mới BitmapCache và BitmapCacheBrush, bạn có thể đệm một phần phức tạp của visual tree như là một ảnh giúp tăng tốc độ dựng hình rất nhiều. Ảnh bitmap này vẫn có khả năng phản hồi lại các thao tác của người dùng như thao tác click chuột, và bạn có thể vẽ nó lên trên một element giống như một bút vẽ.</li>
<li>Hỗ trợ Pixel Shader 3WPF 4 được xây dựng trên ShaderEffect hỗ trợ trong WPF 3.5 SP1 bằng các cho phép các ứng dụng viết ra các hiệu ứng dùng Pixel Shader (PS) 3.0. Mô hình PS 3.0 tinh xảo hơn PS 2.0, nó cho phép tạo ra nhiều hiệu ứng trên các phần cứng hỗ trợ.</li>
</ul>
</div>
</div>
<div>
<div><!-- ApplyClick with current id --> <span style="text-decoration:underline;"><strong>Văn bản</strong></span></div>
<div><a id="sectionToggle5"></a>Một số thay đổi liên quan đến văn bản:</p>
<ul>
<li>Hệ thống dựng hình văn bản mớiHệ thống dựng hình văn bản trong WPF đã được thay mới hoàn toàn. Việc thay đổi này mang lại những cải tiến trong việc cấu hình khả năng hiển thị, độ rõ, và hỗ trợ đa ngữ. Nó cho phép xác định cụ thể các giá trị như độ mịn, mức xám hay chế độ hiển thị ClearType, ngoài ra nó cũng hỗ trợ dạng thức ký tự được tối ưu cho việc hiển thị, để sinh ra các văn bản với độ sắc nét có thể so được với Win32/GDI. Hệ thống dựng hình mới cho phép tối ưu text hinting (điều chỉnh để hiển thi trên các thiết bị hiển thị dạng lưới) và snapping cho cả văn bản tĩnh hoặc động. Hệ thống này cũng hỗ trợ các font với các ảnh bitmap nhúng thay thế cho các font size nhỏ, cho phép nhiều font châu Á hiển thị sắc nét tương đương với Win32/GDI.</li>
<li>Tùy biến chọn văn bản và con trỏ.</li>
</ul>
</div>
</div>
<div>
<div><!-- ApplyClick with current id --></div>
<div><span style="text-decoration:underline;"><strong>Gắn nối</strong></span></div>
<div>Một số thay đổi và cải tiến liên quan đến gắn nối:</div>
<div>
<ul>
<li>Gắn vào các command trong InputBinding: Bạn có thể gắn thuộc tính Command của lớp ImputBinding vào một thực thể được định nghĩa trong code. Các thuộc tính sau là các thuộc tính phụ thuộc (dependency property), vì vậy chúng có thể được dùng cho phép gắn nối:
<ul>
<li><a id="ctl00_MTCS_main_ctl94_ctl00_ctl02" href="http://msdn.microsoft.com/en-us/library/system.windows.input.inputbinding.command%28VS.100%29.aspx">InputBinding..::.Command</a></li>
<li><a id="ctl00_MTCS_main_ctl94_ctl00_ctl03" href="http://msdn.microsoft.com/en-us/library/system.windows.input.inputbinding.commandparameter%28VS.100%29.aspx">InputBinding..::.CommandParameter</a></li>
<li><a id="ctl00_MTCS_main_ctl94_ctl00_ctl04" href="http://msdn.microsoft.com/en-us/library/system.windows.input.inputbinding.commandtarget%28VS.100%29.aspx">InputBinding..::.CommandTarget</a></li>
<li><a id="ctl00_MTCS_main_ctl94_ctl00_ctl05" href="http://msdn.microsoft.com/en-us/library/system.windows.input.keybinding.key%28VS.100%29.aspx">KeyBinding..::.Key</a></li>
<li><a id="ctl00_MTCS_main_ctl94_ctl00_ctl06" href="http://msdn.microsoft.com/en-us/library/system.windows.input.keybinding.modifiers%28VS.100%29.aspx">KeyBinding..::.Modifiers</a></li>
<li><a id="ctl00_MTCS_main_ctl94_ctl00_ctl07" href="http://msdn.microsoft.com/en-us/library/system.windows.input.mousebinding.mouseaction%28VS.100%29.aspx">MouseBinding..::.MouseAction</a></li>
</ul>
<p><a id="ctl00_MTCS_main_ctl94_ctl00_ctl08" href="http://msdn.microsoft.com/en-us/library/system.windows.input.inputbinding%28VS.100%29.aspx">InputBinding</a>, <a id="ctl00_MTCS_main_ctl94_ctl00_ctl09" href="http://msdn.microsoft.com/en-us/library/system.windows.input.mousebinding%28VS.100%29.aspx">MouseBinding</a>, và <a id="ctl00_MTCS_main_ctl94_ctl00_ctl10" href="http://msdn.microsoft.com/en-us/library/system.windows.input.keybinding%28VS.100%29.aspx">KeyBinding</a> nhận data context từ <a id="ctl00_MTCS_main_ctl94_ctl00_ctl11" href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement%28VS.100%29.aspx">FrameworkElement</a>.</li>
<li>Gắn vào Dynamic Objects: WPF hỗ trợ gắn nối dữ liệu vào các đối tượng có implement <a id="ctl00_MTCS_main_ctl94_ctl00_ctl12" href="http://msdn.microsoft.com/en-us/library/system.dynamic.idynamicmetaobjectprovider%28VS.100%29.aspx">IDynamicMetaObjectProvider</a>. Ví dụ, nếu bạn tạo một đối tượng động thừa kế từ <a id="ctl00_MTCS_main_ctl94_ctl00_ctl13" href="http://msdn.microsoft.com/en-us/library/system.dynamic.dynamicobject%28VS.100%29.aspx">DynamicObject</a> trong code, bạn có thể dùng các thẻ mở rộng để gắn nó vào các đối tượng trong XAML.</li>
<li><a id="ctl00_MTCS_main_ctl94_ctl00_ctl14" href="http://msdn.microsoft.com/en-us/library/system.windows.documents.run.text%28VS.100%29.aspx">Run.Text</a> bây giờ là một dependency property. Ưu điểm của điều này là hiện nó đã hỗ trợ gắn nối một chiều, nó cũng hỗ trợ các đặc tính khác của dependency properties, như định dạng và templating.</li>
</ul>
</div>
</div>
<div>
<div><!-- ApplyClick with current id --> <span style="text-decoration:underline;"><strong>XAML Browser Applications</strong></span></div>
<div>Hai tính năng mới được thêm vào XAML browser application (XBAPs).</div>
<div>
<ul>
<li>HTML-XBAP Script Interop: Hiện bạn đã có thể tương tác với trang web chứa XBAP khi ứng dụng được chứa bên trong một HTML frame. XBAP có thể truy cập sâu vào cây HTML và bắt các sự kiện DOM. Để có thêm thông tin, xin tham khảo <a id="ctl00_MTCS_main_ctl95_ctl00_ctl00" href="http://msdn.microsoft.com/en-us/library/system.windows.interop.browserinterophelper%28VS.100%29.aspx">BrowserInteropHelper</a>.</li>
<li>Full-Trust XBAP Deployment: Nếu XBAP của bạn cần full trust, user sẽ được tự động nhận yêu cầu tăng quyền của ClickOnce khi họ cài đặt ứng dụng từ intranet hay một site tin cậy nào đó.</li>
</ul>
<p>Xem thêm thông tin tại <a id="ctl00_MTCS_main_ctl95_ctl00_ctl01" href="http://msdn.microsoft.com/en-us/library/aa970060%28VS.100%29.aspx">WPF XAML Browser Applications Overview</a>.</p>
</div>
</div>
<div>
<div><!-- ApplyClick with current id --> <span style="text-decoration:underline;"><strong>WPF và Windows</strong></span></div>
</div>
<p>Windows 7 taskbar cung cấp các tính năng nâng cao cho phép bạn dùng nút taskbar để truyền đạt thông tin cũng như thực thi một số nhiệm vụ. Các kiểu mới trong namespace <a id="ctl00_MTCS_main_ctl96_ctl00_ctl00" href="http://msdn.microsoft.com/en-us/library/system.windows.shell%28VS.100%29.aspx">System.Windows.Shell</a> cung cấp các lớp wrapper cho các tính năng của thanh taskbar trong Windows 7 và quản lý dữ liệu được truyền đến Windows shell. Ví dụ, kiểu <a id="ctl00_MTCS_main_ctl96_ctl00_ctl01" href="http://msdn.microsoft.com/en-us/library/system.windows.shell.jumplist%28VS.100%29.aspx">JumpList</a> cho phép bạn làm việc với Jump List và <a id="ctl00_MTCS_main_ctl96_ctl00_ctl02" href="http://msdn.microsoft.com/en-us/library/system.windows.shell.taskbariteminfo%28VS.100%29.aspx">TaskbarItemInfo</a> cho phép làm việc với taskbar thumbnail. Các hộp thoại WPF trên Windows 7 và Windows Vista hiện hỗ trợ look and feel của Windows 7 và Window Vista , bao gồm cả custom place.</p>
<div>
<div><!-- ApplyClick with current id --> <span style="text-decoration:underline;"><strong>WPF và trình thiết kế Silverlight</strong></span></div>
<div>Trong Visual Studio 2010, có một số cải tiến trong trình thiết kế giúp bạn trong việc tạo các ứng dụng WPF và Silverlight.</div>
<div>
<ul>
<li>Nâng cao khả năng hỗ trợ Silverlight: Trong VS 2008, bạn có thể cài đặt Silverlight Tools để tạo các ứng dụng Silverlight trong Visual Studio. Tuy nhiên khả năng hỗ trợ Silverlight bị giới hạn. Trong VS 2010, khả năng hỗ trợ Silverlight và WPF là tương đương. Ví dụ, trong các ứng dụng Silverlight bạn có thể dùng chuột để chọn và đặt các đối tượng vào các vị trí trên cửa sổ thiết kế.</li>
<li>Hỗ trợ nhiều phiên bản khác nhau: Trong Visual Studio 2008, các control chỉ hỗ trợ WPF phiên bản mới nhất khi ở chế độ thiết kế. Trong VS 2010, khả năng này được mở rộng cho nhiều nền tảng khác nhau, bao gồm cả WPF 3.5, WPF 4.0, Silverlight 3 và cả các phiên bản trong tương lai.</li>
<li>Visual Databinding: Trình hỗ trợ xây dựng gắn nối dữ liệu cho phép tạo ra và chỉnh sửa các gắn nối một cách trực quan mà không phải gõ code XAML.</li>
<li>Auto Layout: Các cải tiến về layout bao gồm một khả năng hỗ trợ tạo các Grid trực quan hơn và hỗ trợ tốt hơn cho việc tự động thay đổi kích thước của các user control.</li>
<li>Improved Property Editing: Cửa sổ Properties hiện tại đã cho phép tạo và chỉnh sửa các Brush một cách trực quan.</li>
</ul>
<p>Bạn có thể tham khảo thêm tại <a id="ctl00_MTCS_main_ctl97_ctl00_ctl02" href="http://msdn.microsoft.com/en-us/library/bb514656%28VS.100%29.aspx">WPF Designer</a>.</p>
<p>Theo MSDN</p>
</div>
</div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/namdh.wordpress.com/1033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/namdh.wordpress.com/1033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/namdh.wordpress.com/1033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/namdh.wordpress.com/1033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/namdh.wordpress.com/1033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/namdh.wordpress.com/1033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/namdh.wordpress.com/1033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/namdh.wordpress.com/1033/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/namdh.wordpress.com/1033/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/namdh.wordpress.com/1033/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1033&subd=namdh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://namdh.wordpress.com/2009/11/03/whats-new-in-wpf-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">namdh</media:title>
		</media:content>

		<media:content url="http://i.msdn.microsoft.com/Global/Images/clear.gif" medium="image" />
	</item>
		<item>
		<title>StockViewer 0.70</title>
		<link>http://namdh.wordpress.com/2009/09/28/stockviewer-070/</link>
		<comments>http://namdh.wordpress.com/2009/09/28/stockviewer-070/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 16:11:27 +0000</pubDate>
		<dc:creator>namdh</dc:creator>
				<category><![CDATA[Không phân loại]]></category>
		<category><![CDATA[stockviewer]]></category>

		<guid isPermaLink="false">http://namdh.wordpress.com/?p=1027</guid>
		<description><![CDATA[Phiên bản này đã cập nhật đầy đủ bảng thông tin doanh nghiệp niêm yết và cho phép tải về các file tài liệu, báo cáo của doanh nghiệp.



Tải về tại đây: http://www.daohainam.com/download/stockviewer.070.exe
Hi vọng nhận được ý kiến đóng góp của các bạn.

 Tagged: stockviewer      <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1027&subd=namdh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Phiên bản này đã cập nhật đầy đủ bảng thông tin doanh nghiệp niêm yết và cho phép tải về các file tài liệu, báo cáo của doanh nghiệp.</p>
<p><a href="http://namdh.files.wordpress.com/2009/09/svci3.png"><img class="aligncenter size-full wp-image-1028" title="svci3" src="http://namdh.files.wordpress.com/2009/09/svci3.png?w=654&#038;h=512" alt="svci3" width="654" height="512" /></a></p>
<p style="text-align:center;"><a href="http://namdh.files.wordpress.com/2009/09/svci1.png"><img class="size-full wp-image-1029  aligncenter" title="svci1" src="http://namdh.files.wordpress.com/2009/09/svci1.png?w=325&#038;h=285" alt="svci1" width="325" height="285" /></a></p>
<p style="text-align:center;"><a href="http://namdh.files.wordpress.com/2009/09/svci2.png"><img class="size-full wp-image-1030  aligncenter" title="svci2" src="http://namdh.files.wordpress.com/2009/09/svci2.png?w=325&#038;h=285" alt="svci2" width="325" height="285" /></a></p>
<p style="text-align:center;">Tải về tại đây: <a href="http://www.daohainam.com/download/stockviewer.070.exe">http://www.daohainam.com/download/stockviewer.070.exe</a></p>
<p style="text-align:center;">Hi vọng nhận được ý kiến đóng góp của các bạn.</p>
<p style="text-align:center;">
 Tagged: stockviewer <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/namdh.wordpress.com/1027/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/namdh.wordpress.com/1027/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/namdh.wordpress.com/1027/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/namdh.wordpress.com/1027/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/namdh.wordpress.com/1027/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/namdh.wordpress.com/1027/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/namdh.wordpress.com/1027/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/namdh.wordpress.com/1027/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/namdh.wordpress.com/1027/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/namdh.wordpress.com/1027/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1027&subd=namdh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://namdh.wordpress.com/2009/09/28/stockviewer-070/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">namdh</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/09/svci3.png" medium="image">
			<media:title type="html">svci3</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/09/svci1.png" medium="image">
			<media:title type="html">svci1</media:title>
		</media:content>

		<media:content url="http://namdh.files.wordpress.com/2009/09/svci2.png" medium="image">
			<media:title type="html">svci2</media:title>
		</media:content>
	</item>
		<item>
		<title>Clean Web.Config Files (VS 2010 and .NET 4.0 Series)</title>
		<link>http://namdh.wordpress.com/2009/09/19/clean-web-config-files/</link>
		<comments>http://namdh.wordpress.com/2009/09/19/clean-web-config-files/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 01:05:55 +0000</pubDate>
		<dc:creator>namdh</dc:creator>
				<category><![CDATA[Microsoft .NET]]></category>
		<category><![CDATA[VS 2010 and .NET 4.0 Series]]></category>

		<guid isPermaLink="false">http://namdh.wordpress.com/?p=1016</guid>
		<description><![CDATA[Đây là bài đầu tiên trong loạt bài về VS 2010 và .NET 4.0.
Có thể bài viết này hơi ngắn, nhưng đây là một thay đổi hay, thay đổi đầu tiên sẽ đến với bản ASP.NET 4.0 là: file web.config đơn giản, sáng sủa hơn.
Bạn sẽ thấy ngay điều này ngay khi tạo một dự [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1016&subd=namdh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Đây là bài đầu tiên trong loạt bài về VS 2010 và .NET 4.0.</p>
<p>Có thể bài viết này hơi ngắn, nhưng đây là một thay đổi hay, thay đổi đầu tiên sẽ đến với bản ASP.NET 4.0 là: file web.config đơn giản, sáng sủa hơn.</p>
<p>Bạn sẽ thấy ngay điều này ngay khi tạo một dự án ASP.NET 4.0 mới (đó là lý do tại sao tôi chọn bài này là bài đầu tiên).</p>
<p><span id="more-1016"></span></p>
<h3><span style="text-decoration:underline;">Các fileWeb.config trong .NET 3.0 và 3.5</span></h3>
<p>Trong 2 phiên bản vừa rồi, file web.config trong các dự án ASP.NET cứ tăng kích thước dần. Ví dụ: file web.config mặc nhiên được thêm vào dữ án mới trong VS 2008 SP1 có 126 dòng, chứa tất cả mọi thứ từ định nghĩa thẻ cho đến các handler và module được thêm vào ASP.NET Http pipeline.</p>
<p>Điều này làm tăng kích thước bởi vì .NET 3.0 và .NET 3.5 dùng cùng CLR và machine.config giống như trong .NET 2.0 &#8211; và đơn giản là thêm vào và cập nhật các assembly khi nó được cài đặt. Để tránh rủi ro khi vô tình ghi đè các thiết đặt trong file machine.config của bản 2.0, chúng tôi đã không đăng ký thêm các tag, handler và module có trong bản .NET 3.0 hay 3.5. Thay vào đó, chúng tôi đã mặc nhiên bắt các project mới phải đăng ký các cài đặt đó bên trong file web.config riêng. Điều này an toàn hơn, nhưng bù lại các file web.config trở nên lớn và khó đọc hơn.</p>
<h3><span style="text-decoration:underline;">File Web.config trong .NET 4</span></h3>
<p>.NET 4.0 bao gồm một phiên bản mới của CLR, và một file machine.config riêng cho bản 4.0 (nó được cài đặt side-by-side với các file được dùng trong bản .NET 2, .NET 3 và .NET 3.5).</p>
<p>File machine.config có trong .NET 4.0 sẽ tự động đăng ký tất cả các ASP.NET tag section, handler và module mà chúng tôi đã thêm vào trong nhiều năm qua, bao gồm cả cho:</p>
<ul>
<li>ASP.NET AJAX</li>
<li>ASP.NET Dynamic Data</li>
<li>ASP.NET Routing (có thể dùng cho cả ASP.NET WebForms và ASP.NET MVC)</li>
<li>ASP.NET Chart Control (sẽ được đóng gói cùng ASP.NET V4)</li>
</ul>
<p>Có nghĩa là khi bạn tạo một project “Empty ASP.NET application” mới trong VS 2010, bẹn sẽ thấy rằng file web.config mới rõ ràng và sáng sủa hơn:</p>
<p><img src="http://scottguimages.s3.amazonaws.com/web2.png" alt="" /></p>
<p>Phần cấu hình đầu tiên ở trên chỉ đơn giản nói với ASP.NET bật chế độ debug, và chỉ ra phiên bản của .NET mà VS phải dùng khi cung cấp intellisense (VS 2010 hỗ trợ xây dựng ứng dụng cho các phiên bản khác nhau &#8211; và intellisense bên trong IDE sẽ tự động điều chỉnh theo phiên bản của .NET mà bạn đang hướng đến).</p>
<p>Phần thứ hai chỉ ra bạn sẽ dùng chế độ &#8220;integrated&#8221; khi chạy ASP.NET bên trong IIS7 &#8211; nó sẽ kiểm soát việc có chạy các HttpModules cho tất cả các request bên trong ứng dụng hay chỉ cho các URL cụ thể nào đó. Chúng tôi đã mặc nhiên bật tính năng này cho các project mới &#8211; lý do là để tương thích, IIS7 mặc nhiên chỉ chạy các module với các ASP.NET URL.</p>
<h3><span style="text-decoration:underline;">Tổng kết</span></h3>
<p>Việc đơn giản hóa file web.config trong .NET 4 thực sự chỉ là một thay đổi nhỏ &#8211; nhưng dù sao nó cũng là một cái hay, và là cái giúp cho các ứng dung ASP.NET mới sáng sủa và dễ tiếp cận hơn.</p>
<p>Trong các bài viết kế tiếp, tôi dự định sẽ đào sâu vào nhiều các cải tiến quan trọng có trong ASP.NET 4 (cũng như một số các “small but nice tweaks”).</p>
<p>Hope this helps,</p>
<p>Scott</p>
 Tagged: VS 2010 and .NET 4.0 Series <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/namdh.wordpress.com/1016/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/namdh.wordpress.com/1016/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/namdh.wordpress.com/1016/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/namdh.wordpress.com/1016/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/namdh.wordpress.com/1016/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/namdh.wordpress.com/1016/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/namdh.wordpress.com/1016/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/namdh.wordpress.com/1016/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/namdh.wordpress.com/1016/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/namdh.wordpress.com/1016/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1016&subd=namdh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://namdh.wordpress.com/2009/09/19/clean-web-config-files/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">namdh</media:title>
		</media:content>

		<media:content url="http://scottguimages.s3.amazonaws.com/web2.png" medium="image" />
	</item>
		<item>
		<title>VS 2010 and .NET 4 Series</title>
		<link>http://namdh.wordpress.com/2009/09/01/vs-2010-and-net-4-series/</link>
		<comments>http://namdh.wordpress.com/2009/09/01/vs-2010-and-net-4-series/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 01:51:50 +0000</pubDate>
		<dc:creator>namdh</dc:creator>
				<category><![CDATA[Microsoft .NET]]></category>
		<category><![CDATA[VS 2010 and .NET 4 Series]]></category>

		<guid isPermaLink="false">http://namdh.wordpress.com/?p=1003</guid>
		<description><![CDATA[Tiếp theo các loạt bài về LINQ, Silverlight&#8230; trong thời gian tới, tôi sẽ bắt đầu dịch loạt bài VS 2010 and .NET 4 Series của MR.ScottGu. Loạt bài này giới thiệu về những thay đổi có trong phiên bản kế tiếp của .NET và trình IDE nổi tiếng Visual Studio.
Link các bài viết gốc [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1003&subd=namdh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Tiếp theo các loạt bài về LINQ, Silverlight&#8230; trong thời gian tới, tôi sẽ bắt đầu dịch loạt bài VS 2010 and .NET 4 Series của MR.ScottGu. Loạt bài này giới thiệu về những thay đổi có trong phiên bản kế tiếp của .NET và trình IDE nổi tiếng Visual Studio.</p>
<p>Link các bài viết gốc tại đây: <a href="http://weblogs.asp.net/scottgu">http://weblogs.asp.net/scottgu</a></p>
<p>Bài viết này sẽ được cập nhật danh sách các bài dịch.</p>
<p>Hi vọng loạt bài này sẽ giúp chúng ta tìm hiểu kỹ hơn và tận dụng những ưu điểm mới của .NET 4.0 và VS 2010.</p>
 Tagged: VS 2010 and .NET 4 Series <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/namdh.wordpress.com/1003/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/namdh.wordpress.com/1003/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/namdh.wordpress.com/1003/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/namdh.wordpress.com/1003/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/namdh.wordpress.com/1003/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/namdh.wordpress.com/1003/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/namdh.wordpress.com/1003/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/namdh.wordpress.com/1003/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/namdh.wordpress.com/1003/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/namdh.wordpress.com/1003/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=1003&subd=namdh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://namdh.wordpress.com/2009/09/01/vs-2010-and-net-4-series/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">namdh</media:title>
		</media:content>
	</item>
		<item>
		<title>Dùng biểu thức LINQ tùy biến với &lt;asp:LinqDatasource&gt; (LINQ to SQL phần 9)</title>
		<link>http://namdh.wordpress.com/2009/08/05/linq-to-sql-part-9-custom-linq-with-linqdatasource/</link>
		<comments>http://namdh.wordpress.com/2009/08/05/linq-to-sql-part-9-custom-linq-with-linqdatasource/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 03:46:48 +0000</pubDate>
		<dc:creator>namdh</dc:creator>
				<category><![CDATA[Microsoft .NET]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[linq to sql]]></category>

		<guid isPermaLink="false">http://namdh.wordpress.com/?p=968</guid>
		<description><![CDATA[Vài tuần trước tôi bắt đầu viết loạt bài về LINQ to SQL. LINQ to SQL là một bộ khung (framework) có sẵn cho O/RM (object relational mapping) trong .NET 3.5, nó cho phép bạn dễ dàng mô hình hóa các CSDL quan hệ dùng các lớp .NET. Bạn có thể dùng các biểu thức [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=968&subd=namdh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Vài tuần trước tôi bắt đầu viết loạt bài về LINQ to SQL. LINQ to SQL là một bộ khung (framework) có sẵn cho O/RM (object relational mapping) trong .NET 3.5, nó cho phép bạn dễ dàng mô hình hóa các CSDL quan hệ dùng các lớp .NET. Bạn có thể dùng các biểu thức LINQ để truy vấn CSDL, cũng như có thể cập nhật/thêm/xóa dữ liệu từ đó.</p>
<p>Dưới đây là 7 phần đầu tiên của loạt bài này:</p>
<ul>
<li><a rel="bookmark" href="../2008/10/08/linq-to-sql-part-1-using-linq/">Sử dụng LINQ to SQL (phần 1)</a></li>
<li><a rel="bookmark" href="../2008/11/07/linq-to-sql-part-2-modeling-classes/">Định nghĩa các lớp mô hình dữ liệu (phần 2)</a></li>
<li><a rel="bookmark" href="../2008/11/21/linq-to-sql-part-3-querying-database/">Truy vấn Cơ sở dữ liệu (phần 3)</a></li>
<li><a rel="bookmark" href="../2009/01/06/linq-to-sql-part-4-updating-our-database/">Cập nhật cơ sở dữ liệu (LINQ to SQL phần 4)</a></li>
<li><a rel="bookmark" href="../2009/03/20/linq-to-sql-part-5-linqdatasource/">Sử dụng asp:LinqDataSource (phần 5)</a></li>
<li><a rel="bookmark" href="../2009/05/17/getting-data-using-stored-procedure-linq-to-sql-part-6/">Lấy dữ liệu dùng Stored Procedure (LINQ to SQL phần 6)</a></li>
<li><a rel="bookmark" href="../2009/06/22/updating-data-using-stored-procedure-linq-to-sql-part-7/">Cập nhật dữ liệu dùng Stored Procedure (LINQ to SQL phần 7)</a></li>
<li><a rel="bookmark" href="../2009/08/03/excecuting-custom-exp-linq-to-sql-part-8/">Thực thi các biểu thức SQL tùy biến (LINQ to SQL phần 8)</a></li>
</ul>
<p><span id="more-968"></span></p>
<p>Trong phần 5 của loạt bài này tôi đã giới thiệu control &lt;asp:LinqDataSource&gt; mới trong .NET 3.5 và nói về cách dùng nó để gắn nối các control ASP.NET dễ dàng vào các mô hình dữ liệu LINQ to SQL. Tôi cũng đã trình bày một chút về cách dùng chúng trong một bài viết sau đó khi nói về control &lt;asp:ListView&gt;.</p>
<p>Trong cả hai bài viết trên, các câu truy vấn được thực hiện đều tương đối dễ hiểu (mệnh đề Where làm việc chỉ với một bảng dữ liệu). Trong bài viết hôm nay tôi sẽ biểu diễn cách tận dụng khả năng xây dựng các câu truy vấn nhanh chóng với LINQ dùng LinqDataSource, và cách bạn có thể dùng bất kỳ biểu thức LINQ nào để thực hiện truy vấn với nó.</p>
<p><strong><span style="text-decoration:underline;">Tóm tắt: dùng &lt;asp:LinqDataSource&gt; với một mệnh đề where được khai báo</span></strong></p>
<p>Trong 2 bài viết đó tôi đã biểu diễn cách bạn có thể dùng các bộ lọc có sẵn của LinqDataSource để khai báo nhanh một bộ lọc trên một mô hình dữ liêu LINQ to SQL.</p>
<p>Ví dụ, cho là bạn đã tạo ra một mô hình dữ liệu LINQ to SQL của CSDL Northwind (cách dùng đã được nói đến trong phần 2 cuẩ loạt bài này), chúng ta có có thể khai báo một control &lt;asp:LinqDataSource&gt; trên trang với một mệnh để &lt;where&gt; mà nó chỉ trả về các sản phẩm thuộc một chủng loại nào đó (được chỉ ra qua tham số &#8220;categoryid&#8221; của chuỗi query string):</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step0.jpg" alt="" /></p>
<p>Chúng ta có thể trỏ một control &amp;lt;asp:gridview&amp;gt; đến datasource đã tạo và cho phép phân trang, chỉnh sửa và sắp xếp:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step1.jpg" alt="" /></p>
<p>Khi chạy trang trên, chúng ta sẽ có một GridView với khả năng tự động sắp xếp, phân trang cũng như chỉnh sửa dữ liệu dữ trên dữ liệu có trong mô hình dữ liệu của chúng ta:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step2.jpg" alt="" /></p>
<p>Dùng cách khai báo các tham số cho where giống như trên có thể làm việc tốt trong hầu hết trường hợp. Nhưng sẽ thế nào nếu bạn muốn câu lệnh lọc phức tạp hơn? Ví dụ, sẽ thế nào nếu chúng ta chỉ muốn hiển thị các sản phẩm được tạo bới các nhà cung cấp dựa trên một tập động các quốc gia?</p>
<p><span style="text-decoration:underline;"><strong>Dùng các sự kiện Selecting với &lt;asp:LinqDataSource&gt;</strong></span></p>
<p>Để xử lý các trường hợp trên, bạn có thể tạo các hàm xử lý cho các sự kiện &#8220;Selecting&#8221; thuộc control &amp;lt;asp:LinqDataSourc&amp;gt;. Bên trong các hàm xử lý sự kiện này, bạn có thể viết bất kỳ đoạn lệnh nào bạn muốn để lấy về tập kết quả. Bạn có thể làm được điều này với một câu truy vấn LINQ, gọi một thủ tục SPROC hay dùng một biểu thức SQL tùy biến. Một khi đã lấy dữ liệu về, những gì cần làm là gán nó cho thuộc tính &#8220;Result&#8221; của đối tượng LinqDataSourceSelectEventArgs. Control &amp;lt;asp:LinqDataSourc&amp;gt; khi đói sẽ dùng tập kết quả do bạn trả về để làm việc.</p>
<p>Ví dụ, dưới đây là một câu truy vấn LINQ to SQL để lấy về chỉ các sản phẩm từ các nhà cung cấp thuộc các nước được chọn:</p>
<p>VB:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step4.jpg" alt="" /></p>
<p>C#:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step3.jpg" alt="" /></p>
<blockquote><p><em>Ghi chú: Bạn không cần viết câu truy vấn ngay bên trong hàm xử lý sự kiện. Một cách tiếp cận sáng sủa hơn là đưa các câu lệnh truy vấn vào trong các hàm trợ giúp, và sau đó gọi lại chúng từ các hàm xử lý sự kiện. Tôi đã dùng cách tiếp cận này trong phần đầu của bài 8 (dùng hàm trợ giúp GetProductsByCategor). </em></p></blockquote>
<p>Bây giờ, bằng cách dùng hàm xử lý Selecting, mỗi khi chạy bạn sẽ chỉ thấy các sản phẩm được cung cấp bởi các nhà cung cấp đến từ các quốc gia mà chúng ta đã cho trước.</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step5.jpg" alt="" /></p>
<p>Một trong những điều thật sự thú vị là các chức năng phân trang và sắp xếp vẫn làm việc với GridView của chúng ta &#8211; dù rằng chúng ta đã chuyển sang dùng sự kiện Selecting. Và quan trọng là việc phân trang cũng như sắp xếp này được thực hiện bên trong CSDL &#8211; có nghĩa là chúng ta chỉ lấy về 10 sản phẩm từ CSDL mà chúng ta cần để hiển thị cho trang hiện tại trên GridView, điều này giúp việc thực thi hiệu quả hơn rất nhiều.</p>
<p>Bạn có lẽ sẽ tự hỏi &#8211; làm sao nó có thẻ hỗ trợ việc sắp xếp và phân trang hiệu quả như vậy ngay cả khi ta dùng sự kiện Selecting? Lý do là vì câu truy vấn LINQ sẽ không được thực thi tới chừng nào bạn còn chưa lấy kết quả trả về của nó (deferred execution model). Ưu điểm của mô hình này là nó cho phép bạn dễ dàng soạn câu truy vấn trước khi thực thi nó, cũng như dễ dàng đưa thêm các tính năng &#8220;add-on&#8221; và. Bạn có thể tìm hiểu kỹ hơn trong phần 3 của loạt bài này.</p>
<p>Trong hàm xử lý sự kiện &#8220;Selecting&#8221; ở trên chúng ta khai báo câu truy vấn LINQ chúng ta muốn thực thi và sau đó gán nó vào thuộc tính e.Query. Mặc dù vậy, câu lênh LINQ không được thực thi vì chúng ta không lấy kêt quả của nó (bằng cách dùng những hàm như ToArray() hay ToList()). LINQDataSource sau đó sẽ có thể thêm mệnh đề order by, và nối thêm các hàm mở rộng Take() và Skip(), nhờ vậy mà tập kết quả sẽ được phân trang và sắp xếp. Chỉ khi đó LINQDataSource mới thực hiện câu lệnh LINQ và lấy dữ liệu về, và LINQ to SQL sẽ đảm bảo rằng việc sắp xếp và phân trang này được thực hiện bên trong CSDL &#8211; và chỉ có đúng 10 dòng được trả về.</p>
<p>Chú ý dưới đây chúng ta vẫn dùng GridView để chỉnh sửa và xóa dữ liệu, ngay cả khi dùng sự kiện &#8220;Selecting&#8221; của LinqDataSource:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step6.jpg" alt="" /></p>
<p>Khả năng hỗ trợ việc xóa/sửa dữ liệu sẽ còn làm việc chừng nào thuộc tính Query của sự kiện Selecting còn được gán một tập các thực thể cùng loại (ví du: một dãy các đối tượng kiểu Product, Supplier, Category, Order&#8230;). LINQDataSource khi đó sẽ có thể tự động xử lý các trường hợp UI control thực hiện việc cập nhật đối với nó.</p>
<p>Để học thêm về cách cập nhật trong LINQ to SQL, xin đọc lại <a href="../2009/01/06/linq-to-sql-part-4-updating-our-database/">bài 4</a> của loạt bài này. Và sau đó đọc tiếp <a href="../2009/03/20/linq-to-sql-part-5-linqdatasource/">bài 5</a> để xem cách cập nhật với LINQDataSource.</p>
<p><span style="text-decoration:underline;"><strong>Thực hiện các phép chiếu khi truy vấn với sự kiện Selecting</strong></span></p>
<p>Một trong những điểm mạnh của LINQ là khả năng trả về các &#8220;dạng&#8221; dữ liệu tùy biến, hay còn gọi là phép chiếu dữ liệu. Đó là khả năng mà bạn chỉ trả về một tập con các giá trị của thực thể (một số cột nào đó mà thôi), hay trả về các giá trị được tính toán tự động bằng các biểu thức do bạn định nghĩa. Bạn có thể tìm hiểu thêm cách LINQ thực hiện các phép chiếu này trong <a href="../2008/11/21/linq-to-sql-part-3-querying-database/">phần 3 </a>của loạt bài này.</p>
<p>Ví dụ, bạn có thể sửa lại sự kiện hàm xử lý sự kiện Selecting để đưa thông tin vào cho GridView một tập tùy biến các giá trị của Product. Trong grid này, ta sẽ chỉ hiển thị ProductID, ProductName, Product UnitPrice, số lệnh đặt hàng trên sản phẩm này (Number of Orders), và doanh thu của sản phẩm (Revenue). Chúng ta có thể tính toán động 2 giá trị cuối dùng một biểu thức LINQ như dưới đây:</p>
<p>VB:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step9.jpg" alt="" /></p>
<p>C#:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step8.jpg" alt="" /></p>
<blockquote><p><em><span style="text-decoration:underline;">Ghi chú:</span> hàm Sum được dùng để tính toán Revenue ở trên là một ví dụ về &#8220;Phương thức mở rộng&#8221; (<a href="http://weblogs.asp.net/scottgu/archive/2007/03/13/new-orcas-language-feature-extension-methods.aspx" target="_blank">Extension Method</a>). Tham số được truyền cho hàm này là một ví dụ về biểu thức Lambda. Kiểu trả về được tạo bởi biểu thức LINQ là một kiểu vô danh (<a href="http://weblogs.asp.net/scottgu/archive/2007/05/15/new-orcas-language-feature-anonymous-types.aspx" target="_blank">anonymous type</a>) và nó được hình thành từ biểu thức truy vấn. Extension Methods, Lambda Expressions, và Anonymous Types là các đặc tính mới của VB và C# trong VS 2008.</em></p></blockquote>
<p>Kết quả của biểu thức LINQ trên khi gắn nối vào GridView sẽ tương tự như sau:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step7.jpg" alt="" /></p>
<p>Ghi chú rằng việc phân trang và sắp xếp sẽ vẫn làm việc bình thường với GridView của chúng ta &#8211; dù rằng chúng ta đã chuyển sang dùng câu lệnh LINQ tùy biến.</p>
<p>Dù vậy, vẫn có một tính năng sẽ không làm việc khi dùng phép chiếu dữ liệu, đó là việc hỗ trợ cập nhật dữ liệu ngay trong GridView. Đó là vì LINQDataSource không biết  cách nào để cập nhật dữ liệu một cách an toàn. Nếu chúng ta muốn thêm khả năng cập nhật vào cho GridView để hỗ trợ các kiểu trả về tùy biến như vậy, chúng ta hoặc sẽ phải chuyển sang dùng một control ObjectDataSource (ta phải cung cấp thêm phương thức Update để xử lý việc cập nhật), hoặc phải cung cấp thêm một trang để người dùng cập nhật &#8211; và hiển thị môt DetailsView hay FormViewgắn nối và thực thể Product để chỉnh sửa.</p>
<p><span style="text-decoration:underline;"><strong>Tổng kết</strong></span></p>
<p>Bạn có thể dễ dàng thực hiện các thao tác truy vấn thường dùng với mô hình dữ liệu LINQ to SQL dùng khả năng khai báo các bọ lọc của LINQDataSource.</p>
<p>Để thực hiện biểu thức lọc phức tạp hơn, bạn có thể tận dụng ưu điểm của sự kiên Selecting có trong LINQDataSource. Điều này cho phép bạn thực hiện bất kỳ logic nào bạn muốn để  lấy về các dòng dữ liệu phù hợp. Bạn có thể nhiều cách để lấy dữ liệu này, chẳng hạn dùng Query Expressions, gọi Stored Procedures, hay thực hiện một câu truy vấn tùy biến.</p>
<p>Hope this helps,</p>
<p>Scott</p>
<div id="_mcePaste" style="overflow:hidden;position:absolute;left:-10000px;top:2352px;width:1px;height:1px;">
<p>Vài tuần trước tôi bắt đầu viết loạt bài về LINQ to SQL. LINQ to SQL là một bộ khung (framework) có sẵn cho O/RM (object relational mapping) trong .NET 3.5, nó cho phép bạn dễ dàng mô hình hóa các CSDL quan hệ dùng các lớp .NET. Bạn có thể dùng các biểu thức LINQ để truy vấn CSDL, cũng như có thể cập nhật/thêm/xóa dữ liệu từ đó.</p>
<p>Dưới đây là 7 phần đầu tiên của loạt bài này:</p>
<ul>
<li><a rel="bookmark" href="../2008/10/08/linq-to-sql-part-1-using-linq/">Sử dụng LINQ to SQL (phần 1)</a></li>
<li><a rel="bookmark" href="../2008/11/07/linq-to-sql-part-2-modeling-classes/">Định nghĩa các lớp mô hình dữ liệu (phần 2)</a></li>
<li><a rel="bookmark" href="../2008/11/21/linq-to-sql-part-3-querying-database/">Truy vấn Cơ sở dữ liệu (phần 3)</a></li>
<li><a rel="bookmark" href="../2009/01/06/linq-to-sql-part-4-updating-our-database/">Cập nhật cơ sở dữ liệu (LINQ to SQL phần 4)</a></li>
<li><a rel="bookmark" href="../2009/03/20/linq-to-sql-part-5-linqdatasource/">Sử dụng asp:LinqDataSource (phần 5)</a></li>
<li><a rel="bookmark" href="../2009/05/17/getting-data-using-stored-procedure-linq-to-sql-part-6/">Lấy dữ liệu dùng Stored Procedure (LINQ to SQL phần 6)</a></li>
<li><a rel="bookmark" href="../2009/06/22/updating-data-using-stored-procedure-linq-to-sql-part-7/">Cập nhật dữ liệu dùng Stored Procedure (LINQ to SQL phần 7)</a></li>
<li><a rel="bookmark" href="../2009/08/03/excecuting-custom-exp-linq-to-sql-part-8/">Thực thi các biểu thức SQL tùy biến (LINQ to SQL phần 8)</a></li>
</ul>
<p><!--more--></p>
<p>Trong phần 5 của loạt bài này tôi đã giới thiệu control &lt;asp:LinqDataSource&gt; mới trong .NET 3.5 và nói về cách dùng nó để gắn nối các control ASP.NET dễ dàng vào các mô hình dữ liệu LINQ to SQL. Tôi cũng đã trình bày một chút về cách dùng chúng trong một bài viết sau đó khi nói về control &lt;asp:ListView&gt;.</p>
<p>In both of these articles the queries I performed were relatively straight-forward (the where clause worked against a single table of data).  In today&#8217;s blog post I&#8217;ll demonstrate how to use the full query expressiveness of LINQ with the LinqDataSource control, and show how you can use any LINQ to SQL query expression with it.</p>
<p>Trong cả hai bài viết trên, các câu truy vấn được thực hiện đều tương đối dễ hiểu (mệnh đề Where làm việc chỉ với một bảng dữ liệu). Trong bài viết hôm nay tôi sẽ biểu diễn cách tận dụng khả năng xây dựng các câu truy vấn nhanh chóng với LINQ dùng LinqDataSource, và cách bạn có thể dùng bất kỳ biểu thức LINQ nào để thực hiện truy vấn với nó.</p>
<p><strong><span style="text-decoration:underline;">Tóm tắt: dùng &lt;asp:LinqDataSource&gt; với một mệnh đề where được khai báo</span></strong></p>
<p>Trong 2 bài viết đó tôi đã biểu diễn cách bạn có thể dùng các bộ lọc có sẵn của LinqDataSource để khai báo nhanh một bộ lọc trên một mô hình dữ liêu LINQ to SQL.</p>
<p>Ví dụ, cho là bạn đã tạo ra một mô hình dữ liệu LINQ to SQL của CSDL Northwind (cách dùng đã được nói đến trong phần 2 cuẩ loạt bài này), chúng ta có có thể khai báo một control &amp;lt;asp:LinqDataSource&amp;gt; trên trang với một mệnh để &amp;lt;where&amp;gt; mà nó chỉ trả về các sản phẩm thuộc một chủng loại nào đó (được chỉ ra qua tham số &#8220;categoryid&#8221; của chuỗi query string):</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step0.jpg" alt="" /></p>
<p>Chúng ta có thể trỏ một control &amp;lt;asp:gridview&amp;gt; đến datasource đã tạo và cho phép phân trang, chỉnh sửa và sắp xếp:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step1.jpg" alt="" /></p>
<p>Khi chạy trang trên, chúng ta sẽ có một GridView với khả năng tự động sắp xếp, phân trang cũng như chỉnh sửa dữ liệu dữ trên dữ liệu có trong mô hình dữ liệu của chúng ta:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step2.jpg" alt="" /></p>
<p>Dùng cách khai báo các tham số cho where giống như trên có thể làm việc tốt trong hầu hết trường hợp. Nhưng sẽ thế nào nếu bạn muốn câu lệnh lọc phức tạp hơn? Ví dụ, sẽ thế nào nếu chúng ta chỉ muốn hiển thị các sản phẩm được tạo bới các nhà cung cấp dựa trên một tập động các quốc gia?</p>
<p><span style="text-decoration:underline;"><strong>Dùng các sự kiện Selecting với &amp;lt;asp:LinqDataSource&amp;gt;</strong></span></p>
<p>Để xử lý các trường hợp trên, bạn có thể tạo các hàm xử lý cho các sự kiện &#8220;Selecting&#8221; thuộc control &amp;lt;asp:LinqDataSourc&amp;gt;. Bên trong các hàm xử lý sự kiện này, bạn có thể viết bất kỳ đoạn lệnh nào bạn muốn để lấy về tập kết quả. Bạn có thể làm được điều này với một câu truy vấn LINQ, gọi một thủ tục SPROC hay dùng một biểu thức SQL tùy biến. Một khi đã lấy dữ liệu về, những gì cần làm là gán nó cho thuộc tính &#8220;Result&#8221; của đối tượng LinqDataSourceSelectEventArgs. Control &amp;lt;asp:LinqDataSourc&amp;gt; khi đói sẽ dùng tập kết quả do bạn trả về để làm việc.</p>
<p>For example, below is a LINQ to SQL query expression that retrieves only products from suppliers based in a specific set of countries:</p>
<p>VB:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step4.jpg" alt="" /></p>
<p>C#:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step3.jpg" alt="" /></p>
<blockquote><p>Note: you do not need to write your query expression in-line within the event handler.  A cleaner approach would be to encapsulate it within a helper method that you just call from the event handler.  I show how to create one of these helper methods in the beginning of my <a href="http://weblogs.asp.net/scottgu/archive/2007/08/27/linq-to-sql-part-8-executing-custom-sql-expressions.aspx" target="_blank">Part 8</a> blog post (using a GetProductsByCategory helper method).</p></blockquote>
<p>Now when we run our page using the custom Selecting event handler, we&#8217;ll only see those products whose suppliers are located in our array of countries:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step5.jpg" alt="" /></p>
<p>One of the really cool things to notice above is that paging and sorting still work with our GridView &#8211; even though we are using a custom Selecting event to retrieve the data.  This paging and sorting logic happens in the database &#8211; which means we are only pulling back the 10 products from the database that we need to display for the current page index in the GridView (making it super efficient).</p>
<p>You might ask yourself &#8211; how is it possible that we get efficient paging and sorting support even when using a custom selecting event?  The reason is because LINQ uses a deferred execution model &#8211; which means that the query doesn&#8217;t actually execute until you try and iterate over the results.  One of the benefits of this deferred execution model is that it enables you to nicely compose queries out of other queries, and effectively &#8220;add-on&#8221; behavior to them.  You can learn more about this in my <a href="http://weblogs.asp.net/scottgu/archive/2007/06/29/linq-to-sql-part-3-querying-our-database.aspx" target="_blank">LINQ to SQL Part 3 blog post</a>.</p>
<p>In our &#8220;Selecting&#8221; event handler above we are declaring a custom LINQ query we want to execute and are then assigning it to the &#8220;e.Result&#8221; property.  We haven&#8217;t actually executed it yet though (since we didn&#8217;t try and iterate through the results or call ToArray() or ToList() on it).  The LINQDataSource is therefore able to automatically append on a Skip() and Take() operator to the query, as well as apply an &#8220;orderby&#8221; expression to it &#8212; all of these values being automatically calculated from the page index and sort preference of the GridView.  Only then does the LINQDataSource execute the LINQ expression and retrieve the data.  LINQ to SQL then takes care of making sure that the sort and page logic is handled in the database &#8211; and that only the 10 product rows required are returned from it.</p>
<p>Notice below how we can also still use the GridView to edit and delete data, even when using a custom LinqDataSource &#8220;Selecting&#8221; event:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step6.jpg" alt="" /></p>
<p>This editing/deleting support will work as long as our Selecting event assigns a Result query whose result sequence is of regular entity objects (for example: a sequence of type Product, Supplier, Category, Order, etc).  The LINQDataSource can then automatically handle cases where UI controls perform updates against them.</p>
<p>To learn more about how updates work with LINQ to SQL, please read <a href="http://weblogs.asp.net/scottgu/archive/2007/07/11/linq-to-sql-part-4-updating-our-database.aspx" target="_blank">Part 4</a> of this series.  Then read <a href="http://weblogs.asp.net/scottgu/archive/2007/07/16/linq-to-sql-part-5-binding-ui-using-the-asp-linqdatasource-control.aspx" target="_blank">Part 5</a> of the series to see Updates in action with the LinqDataSource.</p>
<h3>Performing Custom Query Projections with the Selecting Event</h3>
<p>One of the powerful features of LINQ is its ability to custom &#8220;shape&#8221; or &#8220;project&#8221; data.  You can do this in a LINQ to SQL expression to indicate that you want to retrieve only a subset of values from an entity, and/or to dynamically compute new values on the fly using custom expressions that you define.  You can learn more about how these LINQ query projection/shaping capabilities in <a href="http://weblogs.asp.net/scottgu/archive/2007/06/29/linq-to-sql-part-3-querying-our-database.aspx" target="_blank">Part 3</a> of this series.</p>
<p>For example, we could modify our &#8220;Selecting&#8221; event handler to populate a GridView to display a custom set of Product information.  In this Grid we&#8217;ll want to display the ProductID, Product Name, Product UnitPrice, the Number of Orders made for this Product, and the total Revenue collected from orders placed for the Product.  We can dynamically compute these last two values using a LINQ expression like below:</p>
<p>VB:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step9.jpg" alt="" /></p>
<p>C#:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step8.jpg" alt="" /></p>
<blockquote><p>Note: The Sum method used in the Revenue statement above is an example of an <a href="http://weblogs.asp.net/scottgu/archive/2007/03/13/new-orcas-language-feature-extension-methods.aspx" target="_blank">Extension Method</a>.  The function it takes is an example of a <a href="http://weblogs.asp.net/scottgu/archive/2007/04/08/new-orcas-language-feature-lambda-expressions.aspx" target="_blank">Lambda expression</a>.  The resulting type created by the LINQ query expression is an <a href="http://weblogs.asp.net/scottgu/archive/2007/05/15/new-orcas-language-feature-anonymous-types.aspx" target="_blank">anonymous type</a> &#8211; since its shape is inferred from the query expression.  Extension Methods, Lambda Expressions, and Anonymous Types are all new language features of VB and C# in VS 2008.</p></blockquote>
<p>The result of our custom LINQ expression when bound to the GridView will be UI like below:</p>
<p><img src="http://www.scottgu.com/blogposts/linqselecting/step7.jpg" alt="" /></p>
<p>Note that paging and sorting still work above with our GridView - even though we are using a custom LINQ shape/projection for the data.</p>
<p>One feature that will not work with custom shapes/projections, though, is inline editing support.  This is because we are doing a custom projection in our Selecting event, and so the LinqDataSource has no way to safely know how to update an underlying entity object.  If we want to add editing support to the GridView with a custom shaped type, we&#8217;d want to either move to using an ObjectDataSource control (where we could supply a custom Update method method to handle the updates), or have the user navigate to a new page when performing updates - and display a DetailsView or FormView control that was bound to a Product entity for editing (and not try and do inline editing with the grid).</p>
<h3>Summary</h3>
<p>You can easily perform common query operations against a LINQ to SQL data model using the built-in declarative filtering support of the LinqDataSource.</p>
<p>To enable more advanced or custom filtering expressions, you can take advantage of the LINQDataSource&#8217;s Selecting event.  This will enable you to perform any logic you want to retrieve and filter LINQ to SQL data.  You can call methods to retrieve this data, use LINQ Query Expressions, call a Stored Procedures, or invoke a Custom SQL Expression to-do this.</p>
<p>Hope this helps,</p>
<p>Scott</p></div>
 Tagged: .net, linq to sql <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/namdh.wordpress.com/968/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/namdh.wordpress.com/968/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/namdh.wordpress.com/968/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/namdh.wordpress.com/968/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/namdh.wordpress.com/968/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/namdh.wordpress.com/968/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/namdh.wordpress.com/968/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/namdh.wordpress.com/968/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/namdh.wordpress.com/968/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/namdh.wordpress.com/968/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=968&subd=namdh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://namdh.wordpress.com/2009/08/05/linq-to-sql-part-9-custom-linq-with-linqdatasource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">namdh</media:title>
		</media:content>

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step0.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step1.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step2.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step4.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step3.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step5.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step6.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step9.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step8.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step7.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step0.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step1.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step2.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step4.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step3.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step5.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step6.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step9.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step8.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linqselecting/step7.jpg" medium="image" />
	</item>
		<item>
		<title>Thực thi các biểu thức SQL tùy biến (LINQ to SQL phần 8)</title>
		<link>http://namdh.wordpress.com/2009/08/03/excecuting-custom-exp-linq-to-sql-part-8/</link>
		<comments>http://namdh.wordpress.com/2009/08/03/excecuting-custom-exp-linq-to-sql-part-8/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 09:09:53 +0000</pubDate>
		<dc:creator>namdh</dc:creator>
				<category><![CDATA[Microsoft .NET]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[linq to sql]]></category>

		<guid isPermaLink="false">http://namdh.wordpress.com/?p=954</guid>
		<description><![CDATA[Vài tuần trước tôi bắt đầu viết loạt bài về LINQ to SQL. LINQ to SQL là một bộ khung (framework) có sẵn cho O/RM (object relational mapping) trong .NET 3.5, nó cho phép bạn dễ dàng mô hình hóa các CSDL quan hệ dùng các lớp .NET. Bạn có thể dùng các biểu thức [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=954&subd=namdh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Vài tuần trước tôi bắt đầu viết loạt bài về LINQ to SQL. LINQ to SQL là một bộ khung (framework) có sẵn cho O/RM (object relational mapping) trong .NET 3.5, nó cho phép bạn dễ dàng mô hình hóa các CSDL quan hệ dùng các lớp .NET. Bạn có thể dùng các biểu thức LINQ để truy vấn CSDL, cũng như có thể cập nhật/thêm/xóa dữ liệu từ đó.</p>
<p>Dưới đây là 7 phần đầu tiên của loạt bài này:</p>
<ul>
<li><a rel="bookmark" href="../2008/10/08/linq-to-sql-part-1-using-linq/">Sử dụng LINQ to SQL (phần 1)</a></li>
<li><a rel="bookmark" href="../2008/11/07/linq-to-sql-part-2-modeling-classes/">Định nghĩa các lớp mô hình dữ liệu (phần 2)</a></li>
<li><a rel="bookmark" href="../2008/11/21/linq-to-sql-part-3-querying-database/">Truy vấn Cơ sở dữ liệu (phần 3)</a></li>
<li><a rel="bookmark" href="../2009/01/06/linq-to-sql-part-4-updating-our-database/">Cập nhật cơ sở dữ liệu (LINQ to SQL phần 4)</a></li>
<li><a rel="bookmark" href="../2009/03/20/linq-to-sql-part-5-linqdatasource/">Sử dụng asp:LinqDataSource (phần 5)</a></li>
<li><a rel="bookmark" href="../2009/05/17/getting-data-using-stored-procedure-linq-to-sql-part-6/">Lấy dữ liệu dùng Stored Procedure (LINQ to SQL phần 6)</a></li>
<li><a rel="bookmark" href="../2009/06/22/updating-data-using-stored-procedure-linq-to-sql-part-7/">Cập nhật dữ liệu dùng Stored Procedure (LINQ to SQL phần 7)</a></li>
</ul>
<p><span id="more-954"></span></p>
<p>Trong hai bài cuối (bài 6 và bài 7), tôi đã biểu diễn cách bạn có thể dùng các thủ tục trong CSDL (SPROC) để thực hiện truy vấn, cập nhật, thêm hoặc xóa dữ liệu dùng mô hình dữ liệu LINQ to SQL.</p>
<p>Có một vài bạn đã hỏi tôi khi viết các bài này là &#8220;Liệu tôi có thể kiểm soát hoàn toàn các câu SQL được dùng bởi LINQ to SQL mà không cần phải viết các SPROC?&#8221;. Trong bài viết này tôi sẽ nói về điều này &#8211; và thảo luận cách bạn có thể viết các câu SQL tùy biến để truy vấn, cũng như để thêm, sửa hay xóa dữ liệu.</p>
<p>Dùng các biểu thức truy vấn LINQ với LINQ to SQL</p>
<p>Trong bài viết này, chúng ta sẽ dùng mô hình mô hình dữ liệu được tạo với CSDL Northwind (xin hãy đọc <a href="../2008/11/07/linq-to-sql-part-2-modeling-classes/">phần 2</a> để học cách dùng VS 2008 để tạo ra mô hình này):</p>
<p><img src="http://www.scottgu.com/blogposts/linqtosql7/step1.jpg" alt="" /></p>
<p>Trong <a href="../2008/11/21/linq-to-sql-part-3-querying-database/">phần 3</a>, tôi đã cho các bạn thấy cách dùng ngôn ngữ LINQ mới được đưa vào VB và C# để truy vấn mô hình dữ liệu ở trên và trả về một tập đối tượng biểu diễn các dòng/cột trong CSDL.</p>
<p>Ví dụ, bạn có thể thêm một phương thức trợ giúp &#8220;GetProductsByCategory&#8221; vào lớp DataContext trong mô hình dữ liệu của chúng ta mà nó sẽ dùng một các truy vấn LINQ để trả về các đối tượng Product từ CSDL:</p>
<p>VB:</p>
<p><img src="http://www.scottgu.com/blogposts/linq8/step0.jpg" alt="" /></p>
<p>C#:</p>
<p><img src="http://www.scottgu.com/blogposts/linq8/step1.jpg" alt="" /></p>
<p>Một khi bạn đã định nghĩa phương thức LINQ như trên, bạn có thể viết lệnh giống như dưới đây để dùng nó lấy về các sản phẩm, và duyệt qua tập kết quả trả về:</p>
<p>VB:</p>
<p><img src="http://www.scottgu.com/blogposts/linq8/step3.jpg" alt="" /></p>
<p>Khi biểu thức LINQ bên trong phương thức &#8220;GetProductsByCategory&#8221; được thực thi, trình quản ly LINQ to SQL sẽ tự động thực thi câu SQL động để lấy về dữ liệu Product và tạo ra danh sách các đối tượng Product. Bạn có thể dùng trình debug để xem cách biểu thức LINQ này thực thi.</p>
<p><span style="text-decoration:underline;"><strong>Dùng các câu truy vấn SQL tùy biến với LINQ to SQL</strong></span></p>
<p>Trong ví dụ mẫu ở trên chúng ta đã không viết bất kỳ câu lệnh SQL nào để truy vấn dữ liệu và lấy về các đống tượng có kiểu Product. Thay vì vậy, LINQ to SQL sẽ tự đọng dịch biểu thức LINQ thành câu lệnh SQL chúng ta và thực thi nó trong CSDL.</p>
<p>Nhưng liệu nếu chúng ta muốn kiểm soát hoàn toàn câu lệnh SQL được thực thi với CSDL, và không muôn LINQ to SQL làm điều đó tự động? Một cách để làm điều này là dùng một SPROC giống như tôi đã trình bày trong bài 6 và bài 7. Một cách khác là dùng phương thức &#8220;ExcecuteQuery&#8221; trong lớp DataContext để thực thi một câu SQL do chúng ta cung cấp.</p>
<p><span style="text-decoration:underline;"><strong>Dùng ExecuteQuery</strong></span></p>
<p>Phương thức ExecuteQuery nhận vào một câu SQL, cùng với một tập các tham số mà ta có thể dùng để tạo nên câu SQL. Bằng cách dùng nó, bạn có thể thực thi bất kỳ câu lệnh SQL bạn muốn với CSDL (kể các câu lệnh JOIN nhiều bảng).</p>
<p>Điều làm cho ExecuteQuery thực sự hữu dụng là nó cho phép bạn chỉ ra cách nó trả về dữ liệu. Bạn có thể làm được điều này bằng cách truyền một đối tượng có kiểu mong muốn như một tham số của phương thức, hay dùng kiểu generic.</p>
<p>Ví dụ, bạn có thể thay đổi phương thức GetProductsByCategory() được tạo ra trước đây &#8211; phiên bản dùng một biểu thức LINQ &#8211; để dùng phương thức ExecuteQuery thực thi một câu SQL với CSDL và trả về một tập đối tượng Product như kết quả:</p>
<p>VB:</p>
<p><img src="http://www.scottgu.com/blogposts/linq8/step4.jpg" alt="" /></p>
<p>C#:</p>
<p><img src="http://www.scottgu.com/blogposts/linq8/step5.jpg" alt="" /></p>
<p>Chúng ta có thể gọi GetProductsByCategory() dùng cùng cách như trước đây:</p>
<p><img src="http://www.scottgu.com/blogposts/linq8/step3.jpg" alt="" /></p>
<p>Nhưng không như trước đây, trong trường hợp này câu SQL tùy biến sẽ được gọi thay cho câu SQL động được tạo bởi biểu thức LINQ.</p>
<p><span style="text-decoration:underline;"><strong>Tùy biến các biểu thức SQL và theo vết (tracking) các thao tác cập nhật:</strong></span></p>
<p>Mặc nhiên, khi bạn lấy về một mô hình dữ liệu dùng LINQ to SQL, nó sẽ lưu lại các thay đổi mà bạn làm. Nếu gọi phương thức  &#8220;SubmitChanges()&#8221; trên lớp DataContext, nó sẽ lưu lại các thay đổi vào CSDL. Tôi đã nói chi tiết về vấn đề này trong phần 4 của loạt bài này.</p>
<p>Một trong nhưng tính năng nổi trọi của ExecuteQuery là nó có thể kết hợp hoàn toàn vào quá trình theo vết và cập nhật lại mô hình dữ liệu. Ví dụ, bạn có thể viết đoạn lệnh dưới đây để lấy về tất cả các sản phẩm từ một chủng loại nào đó và giảm giá toàn bộ 10%:</p>
<p><img src="http://www.scottgu.com/blogposts/linq8/step6.jpg" alt="" /></p>
<p>Bởi vì chúng ta đã chỉ ra rõ kiểu trả về của câu lệnh ExecuteQuery trong phương thức GetProductsByCategory, do vậy LINQ to SQL sẽ biết cách để dò ra các thay đổi trên các đối tượng Product mà chúng ta trả về,  và khi gọi &#8220;SubmitChanges()&#8221; trên đối tượng đó, chúng sẽ được lưu lại trong SCDL.</p>
<p><span style="text-decoration:underline;"><strong>Tùy biến các biểu thức SQL với các lớp của bạn</strong></span></p>
<p>Phương thức ExecuteQuery()  cho phép bạn chỉ ra bất kỳ lớp nào như kiểu trả về của câu truy vấn. Lớp này không nhất thiết phải được tạo ra bởi trình LINQ to SQL designer, hay phải thừa kế từ bất kỳ class/interface nào.</p>
<p>Ví dụ, bạn có thể định nghĩa một lớp ProductSummary mới chứa các thuộc tính là tập con của Product như dưới đây (chú ý là chúng ta dùng đặc tính <a href="http://weblogs.asp.net/scottgu/archive/2007/03/08/new-c-orcas-language-features-automatic-properties-object-initializers-and-collection-initializers.aspx" target="_blank">Automatic Properties</a> mới có trong C#):</p>
<p><img src="http://www.scottgu.com/blogposts/linq8/step7.jpg" alt="" /></p>
<p>Chúng ta có thể sau đó tạo ra một phương thức tên là GetProductSummariesByCategory() trong lớp NorthwindDataContext, nó sẽ trả về các kết quả dựa trên kiểu ProductSummary. Để ý là câu SQL dưới đây chỉ yêu cầu các thuộc tính của Product nó cần &#8211; ExecuteQuery sẽ tự biết cách đưa các giá trị đó vào các đối tượng ProductSummary mà nó sẽ trả về.</p>
<p><img src="http://www.scottgu.com/blogposts/linq8/step8.jpg" alt="" /></p>
<p>Sau đó chúng ta có thể dùng phương thức này để truy vấn và duyệt qua tập kết quả trả về:</p>
<p><img src="http://www.scottgu.com/blogposts/linq8/step9.jpg" alt="" /></p>
<p><span style="text-decoration:underline;"><strong>Tùy biến các câu SQL cho Inserts/Updates/Deletes</strong></span></p>
<p>Thêm vào việc dùng các biểu thức SQL tùy biến để truy vấn, bạn cũng có thể dùng chúng để thực hiện các thao tác như thêm/xóa/sửa.</p>
<p>Chúng ta có thể làm được điều này bằng cách tạo ra các phương thức partial trong lớp DataContext tương ứng các thao tác Insert/Update/Delete cho thực thể mà chúng ta muốn thay đổi. Và chúng ta sau đó có thể dùng phương thức ExecuteCommand để thực thi các câu SQL cần thiết. Ví dụ, để thay thế hành vi Delete mặc nhiên cho lớp Product, bạn có thể định nghĩa một phương thức partial DeleteProduct như sau:</p>
<p><img src="http://www.scottgu.com/blogposts/linq8/step10.jpg" alt="" /></p>
<p>Và bây giờ, nếu bạn viết đọa code dưới đây để xóa một Product nào đó khỏi CSDL, LINQ to SQL sẽ gọi phương thức DeleteProduct &#8211; và khi đó các câu SQL tùy biến sẽ được thực thi thay thế cho câu SQL được sinh ra tự động bởi LINQ to SQL:</p>
<p><img src="http://www.scottgu.com/blogposts/linq8/step11.jpg" alt="" /></p>
<p><span style="text-decoration:underline;"><strong>Tổng kết</strong></span></p>
<p>Trình quản lý LINQ to SQL tự động tạo ra và thực thi các câu SQL động để thực hiện các câu truy vấn, cập nhật, thêm và xóa dữ liệu trong CSDL.</p>
<p>Đối với một số trường hợp, khi bạn muốn kiểm soát hoàn toàn câu lệnh SQL được thực thi, bạn có thể dùng các thủ tục SPROC, hay cũng có thể viết các câu SQL của riêng bạn. Điều này cung cấp khả năng tùy biến mạnh mẽ khi xây dựng các lớp truy cập dữ liệu.</p>
<p>Trong bài viết tiếp theo, tôi sẽ nói đến một số khái niệm còn lại như: Single Table Inheritance, Deferred/Eager Loading, Optimistic Concurrency, và sử dụng trong hô mình Multi-Tier.</p>
<p>Hope this helps,</p>
<p>Scott</p>
 Tagged: .net, linq to sql <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/namdh.wordpress.com/954/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/namdh.wordpress.com/954/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/namdh.wordpress.com/954/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/namdh.wordpress.com/954/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/namdh.wordpress.com/954/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/namdh.wordpress.com/954/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/namdh.wordpress.com/954/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/namdh.wordpress.com/954/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/namdh.wordpress.com/954/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/namdh.wordpress.com/954/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=namdh.wordpress.com&blog=4017103&post=954&subd=namdh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://namdh.wordpress.com/2009/08/03/excecuting-custom-exp-linq-to-sql-part-8/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">namdh</media:title>
		</media:content>

		<media:content url="http://www.scottgu.com/blogposts/linqtosql7/step1.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linq8/step0.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linq8/step1.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linq8/step3.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linq8/step4.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linq8/step5.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linq8/step3.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linq8/step6.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linq8/step7.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linq8/step8.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linq8/step9.jpg" medium="image" />

		<media:content url="http://www.scottgu.com/blogposts/linq8/step10.jpg" medium="image" />

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