<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">博客园_普若伽门的黑白</title><subtitle type="text">@Web.NET Dev Online </subtitle><id>http://feed.cnblogs.com/blog/u/32633/rss</id><updated>2011-03-31T06:57:16Z</updated><author><name>普若伽门</name><uri>http://www.cnblogs.com/x116/</uri></author><generator>CNBlogs BlogServer</generator><link rel="alternate" type="text/html" href="http://www.cnblogs.com/x116/"/><link rel="self" type="application/atom+xml" href="http://feed.cnblogs.com/blog/u/32633/rss"/><entry><id>http://www.cnblogs.com/x116/articles/1819553.html</id><title type="text">工厂模型代码（备份）</title><summary type="text"/><published>2010-09-06T10:21:00Z</published><updated>2010-09-06T10:21:00Z</updated><author><name>普若伽门</name><uri>http://www.cnblogs.com/x116/</uri></author><link rel="alternate" href="http://www.cnblogs.com/x116/articles/1819553.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/x116/articles/1819553.html"/><content type="html">&lt;div &gt;&#xD;
&lt;pre &gt;using System;&#xD;
using System.Collections.Generic;&#xD;
&#xD;
namespace Factory{&#xD;
	public interface ExportFileApi{&#xD;
		bool Export(string data);&#xD;
	}&#xD;
	&#xD;
	public class ExportTxtFile : ExportFileApi{&#xD;
		public bool Export(string data){&#xD;
			Console.WriteLine("txt file:"+data);	&#xD;
			return true;&#xD;
		}	&#xD;
	}	&#xD;
	&#xD;
	public class ExportDBFile : ExportFileApi{&#xD;
		public bool Export(string data){&#xD;
			Console.WriteLine("DB file:"+data);	&#xD;
			return true;&#xD;
		}	&#xD;
	}&#xD;
	&#xD;
	public abstract class ExportOperate{&#xD;
		public bool Export(string data){&#xD;
			ExportFileApi api=FactoryMethod();&#xD;
			return api.Export(data);&#xD;
		}&#xD;
		protected abstract ExportFileApi FactoryMethod();&#xD;
	}&#xD;
	&#xD;
	public class ExportTxtOperate :ExportOperate{&#xD;
		protected override ExportFileApi FactoryMethod(){&#xD;
			return new ExportTxtFile();&#xD;
		}&#xD;
	}&#xD;
	&#xD;
	public class ExportDBOperate :ExportOperate{&#xD;
		protected override ExportFileApi FactoryMethod(){&#xD;
			return new ExportDBFile();&#xD;
		}&#xD;
	}	&#xD;
	&#xD;
	public class MyClass&#xD;
	&#xD;
	{&#xD;
		public static void Main()&#xD;
		{&#xD;
			ExportOperate operate=new ExportDBOperate();&#xD;
			operate.Export("测试数据");&#xD;
			Console.ReadLine();				&#xD;
		}	&#xD;
	}&#xD;
}&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&lt;img src="http://www.cnblogs.com/x116/aggbug/1819553.html?type=2" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/x116/articles/1819553.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/x116/articles/1818950.html</id><title type="text">快速排序JS代码</title><summary type="text">网上转了一圈，看到各种变种的快排程序，却没有标准快排的示例代码，于是自己填了段，做记忆用方便以后查询。</summary><published>2010-09-06T04:04:00Z</published><updated>2010-09-06T04:04:00Z</updated><author><name>普若伽门</name><uri>http://www.cnblogs.com/x116/</uri></author><link rel="alternate" href="http://www.cnblogs.com/x116/articles/1818950.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/x116/articles/1818950.html"/><content type="html">&lt;p&gt;网上转了一圈，看到各种变种的快排程序，却没有标准快排的示例代码，于是自己填了段，做记忆用方便以后查询。&#xD;
&lt;/p&gt;&#xD;
&lt;div &gt;&#xD;
&lt;pre &gt;function main(){&#xD;
		var list=new Array(93,1,7,9,8,3,10,33,79,45,32,11,0,88,99,12,4,66,64,31,78,100);&#xD;
		//list=quickSort(list);		&#xD;
		document.write(sort(list).valueOf());&#xD;
	}&#xD;
	&#xD;
	function sort(arr){&#xD;
		return quickSort(arr,0,arr.length-1);&#xD;
		function quickSort(arr,l,r){			&#xD;
			if(l&amp;lt;r){			&#xD;
				var mid=arr[parseInt((l+r)/2)],i=l-1,j=r+1;			&#xD;
				while(true){&#xD;
					while(arr[++i]&amp;lt;mid);&#xD;
					while(arr[--j]&amp;gt;mid);				&#xD;
					if(i&amp;gt;=j)break;&#xD;
					var temp=arr[i];&#xD;
					arr[i]=arr[j];&#xD;
					arr[j]=temp;&#xD;
				}		&#xD;
				quickSort(arr,l,i-1);&#xD;
				quickSort(arr,j+1,r);&#xD;
			}&#xD;
			return arr;&#xD;
		}&#xD;
	}&#xD;
&lt;/pre&gt;&#xD;
&lt;/div&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/x116/aggbug/1818950.html?type=2" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/x116/articles/1818950.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/x116/archive/2010/06/13/1757918.html</id><title type="text">JS模板引擎jTemplates 使用笔记（二）:Live Refresh!</title><summary type="text">1. 功能简介 允许选择的元素进行自动更新；使用简单但功能强大。 2. 方法说明 Updater&amp;#160; jQuery.fn.processTemplateStart(String url, Array param, Integer interval, [Array args], [Object options]); void&amp;#160; jQuery.fn.processTemplateSt...</summary><published>2010-06-13T09:18:00Z</published><updated>2010-06-13T09:18:00Z</updated><author><name>普若伽门</name><uri>http://www.cnblogs.com/x116/</uri></author><link rel="alternate" href="http://www.cnblogs.com/x116/archive/2010/06/13/1757918.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/x116/archive/2010/06/13/1757918.html"/><content type="html">&lt;p&gt;&lt;strong&gt;1. 功能简介&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote style='border:2px solid #EFEFEF;color:#333333;padding:5px 10px;'&gt;   &lt;p&gt;允许选择的元素进行自动更新；使用简单但功能强大。&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;2. 方法说明&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote style='border:2px solid #EFEFEF;color:#333333;padding:5px 10px;'&gt;   &lt;p&gt;Updater&amp;#160; jQuery.fn.processTemplateStart(String url, Array param, Integer interval, [Array args], [Object options]);&lt;/p&gt;    &lt;p&gt;void&amp;#160; jQuery.fn.processTemplateStop();&lt;/p&gt;    &lt;p&gt;参数详细介绍请参考官方文档&lt;a href="http://jtemplates.tpython.com/" target="_blank"&gt;jTemplates&lt;/a&gt;。&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;3. 简单示例&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote style='border:2px solid #EFEFEF;color:#333333;padding:5px 10px;'&gt;   &lt;p&gt;本示例使用MVC框架搭建&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;&lt;strong&gt;I:使用*.Aspx搭建展示内容页&lt;/strong&gt;&lt;/strong&gt;&lt;/p&gt;    &lt;pre &gt;&amp;lt;script src=&amp;quot;&amp;lt;%=Url.Content(&amp;quot;~/Scripts/jquery-jtemplates.js&amp;quot;) %&amp;gt;&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&#xD;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; &amp;gt;&#xD;
&amp;lt;!--&#xD;
$(function() {&#xD;
	var temp='&amp;lt;a href=&amp;quot;#result&amp;quot; id=&amp;quot;start&amp;quot;&amp;gt;start&amp;lt;/a&amp;gt;'&#xD;
		+'&amp;lt;a href=&amp;quot;#result&amp;quot; id=&amp;quot;stop&amp;quot;&amp;gt;stop&amp;lt;/a&amp;gt;'&#xD;
		+'&amp;lt;div id=&amp;quot;infobox&amp;quot;&amp;gt;-&amp;lt;/div&amp;gt;';&#xD;
	&#xD;
	$(&amp;quot;#result&amp;quot;).setTemplateURL(temp);&#xD;
	$(&amp;quot;#result&amp;quot;).processTemplate();&#xD;
&#xD;
	//设置模板内容&#xD;
	$(&amp;quot;#infobox&amp;quot;).setTemplate('{$T.Time}');&#xD;
&#xD;
	var i = 0;&#xD;
	$(&amp;quot;#start&amp;quot;).click(function() {&#xD;
		$(&amp;quot;#infobox&amp;quot;)&#xD;
		.processTemplateStart('&amp;lt;%=Url.Action(&amp;quot;GetLiveData&amp;quot;)%&amp;gt;',null,1000);&#xD;
		&#xD;
	});&#xD;
&#xD;
	$(&amp;quot;#stop&amp;quot;).click(function() {&#xD;
		$(&amp;quot;#infobox&amp;quot;).processTemplateStop();&#xD;
	});&#xD;
});&#xD;
	&#xD;
//--&amp;gt;&#xD;
&amp;lt;/script&amp;gt;&#xD;
&amp;lt;div id=&amp;quot;result&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;/pre&gt;&#xD;
&#xD;
  &lt;p&gt;&lt;strong&gt;&lt;strong&gt;I:Controller 和 Model&lt;/strong&gt;&lt;/strong&gt;&lt;/p&gt;&#xD;
&#xD;
  &lt;p&gt;&lt;strong&gt;Controller代码:&lt;/strong&gt;&lt;/p&gt;&#xD;
&#xD;
  &lt;pre &gt;public ActionResult GetLiveData()&#xD;
{&#xD;
	return Json(new LiveModel&#xD;
	           {&#xD;
	            Time = DateTime.Now.ToString()&#xD;
	           }, JsonRequestBehavior.AllowGet);&#xD;
}&#xD;
&#xD;
public ActionResult GetLiveTemplate()&#xD;
{&#xD;
	return PartialView(&amp;quot;RefreshTemp&amp;quot;);&#xD;
}&#xD;
&#xD;
public ActionResult LiveRefresh()&#xD;
{&#xD;
	return View();&#xD;
}&lt;/pre&gt;&#xD;
&#xD;
  &lt;p&gt;&lt;strong&gt;Model代码:&lt;/strong&gt;&lt;/p&gt;&#xD;
&#xD;
  &lt;pre &gt;public class LiveModel&#xD;
{&#xD;
	public string Time { get; set; }&#xD;
&#xD;
}&lt;/pre&gt;&#xD;
&#xD;
  &lt;p&gt;&lt;/p&gt;&#xD;
&lt;/blockquote&gt;&#xD;
&#xD;
&lt;p&gt;&lt;strong&gt;4. 最终效果图&lt;/strong&gt;&lt;/p&gt;&#xD;
&#xD;
&lt;blockquote style='border:2px solid #EFEFEF;color:#333333;padding:5px 10px;'&gt;&#xD;
  &lt;p&gt;&lt;img src="http://wwmxaw.blu.livefilestore.com/y1pRRj4J-HVLfnTtWyczR_qoJkT2UH29EksBF1jBRiVU3EWNu0ZJLGy9mRIS2xhprSMe2BDX0pDHi0npZvZVFECxL8Iq1msN-PD/liveRefresh.jpg" /&gt; &lt;/p&gt;&#xD;
&lt;/blockquote&gt;&#xD;
&#xD;
&lt;p&gt;&lt;strong&gt;5. 小结和备注&lt;/strong&gt;&lt;/p&gt;&#xD;
&#xD;
&lt;p&gt;目前在IE环境下,通过Ajax的Get同一个地址会从CACHE中获取。于是该示例中结果会保持不变。但在FF,chrome中均正常。&lt;/p&gt;&lt;img src="http://www.cnblogs.com/x116/aggbug/1757918.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/x116/archive/2010/06/13/1757918.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/x116/archive/2010/06/12/1757236.html</id><title type="text">JS模板引擎jTemplates 使用笔记（一）</title><summary type="text">1 引擎简介 jTemplates是一个基于Jquery的js模板引擎插件。该引擎全部代码由JS实现，可以配合AJAX,JSON一起协同工作，模板内容可以用JS代码，实现了活动更新，可以自动从服务器更新模板生成的内容。 jTemplates能免费应用于商业和非商业。2 下载引用 最新版本号：0.7.8 示例包：http://jtemplates.tpython.com/jTemplates.zip...</summary><published>2010-06-12T08:21:00Z</published><updated>2010-06-12T08:21:00Z</updated><author><name>普若伽门</name><uri>http://www.cnblogs.com/x116/</uri></author><link rel="alternate" href="http://www.cnblogs.com/x116/archive/2010/06/12/1757236.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/x116/archive/2010/06/12/1757236.html"/><content type="html">&lt;p&gt;&lt;strong&gt;1 引擎简介&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;a target="_blank" href="http://jtemplates.tpython.com/"&gt;jTemplates&lt;/a&gt;是一个基于Jquery的js模板引擎插件。该引擎全部代码由JS实现，可以配合AJAX,JSON一起协同工作，模板内容可以用JS代码，实现了活动更新，可以自动从服务器更新模板生成的内容。 &#xD;
  &lt;br /&gt;&amp;nbsp; &lt;a target="_blank" href="http://jtemplates.tpython.com/"&gt;jTemplates&lt;/a&gt;能免费应用于商业和非商业。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;2 下载引用&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;最新版本号：0.7.8 &#xD;
  &lt;br /&gt;&amp;nbsp; 示例包：&lt;a target="_blank" href="http://jtemplates.tpython.com/jTemplates.zip"&gt;http://jtemplates.tpython.com/jTemplates.zip&lt;/a&gt; &#xD;
  &lt;br /&gt;&amp;nbsp; 压缩后：&lt;a target="_blank" href="http://jtemplates.tpython.com/jTemplates/jquery-jtemplates.js"&gt;http://jtemplates.tpython.com/jTemplates/jquery-jtemplates.js&lt;/a&gt; &#xD;
  &lt;br /&gt;&amp;nbsp; 未压缩：&lt;a target="_blank" href="http://jtemplates.tpython.com/jTemplates/jquery-jtemplates_uncompressed.js"&gt;http://jtemplates.tpython.com/jTemplates/jquery-jtemplates_uncompressed.js&lt;/a&gt; &lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;3 简单示例&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;本Demo使用MVC框架搭建。 &#xD;
  &lt;br /&gt;&amp;nbsp; I：使用*.ASCX搭建模板内容 &#xD;
  &lt;br /&gt;&amp;nbsp; 主要代码 &lt;/p&gt;&#xD;
&lt;pre &gt;{#template MAIN}&#xD;
 &amp;lt;div id="header"&amp;gt;{$T.Name}&amp;lt;/div&amp;gt;&#xD;
 &amp;lt;table&amp;gt;&#xD;
 {#foreach $T.Peoples as record}&#xD;
  {#include ROW root=$T.record}&#xD;
 {#/for}&#xD;
 &amp;lt;/table&amp;gt;&#xD;
{#/template MAIN}&#xD;
&#xD;
{#template ROW}&#xD;
 &amp;lt;tr bgcolor="{#cycle values=['#AAAAEE','#CCCCFF']}"&amp;gt;&#xD;
  &amp;lt;td&amp;gt;{$T.FirstName.bold()}&amp;lt;/td&amp;gt;&#xD;
  &amp;lt;td&amp;gt;{$T.Age}&amp;lt;/td&amp;gt;&#xD;
  &amp;lt;td&amp;gt;{$T.Email.link('mailto:'+$T.Email)}&amp;lt;/td&amp;gt;&#xD;
 &amp;lt;/tr&amp;gt;&#xD;
{#/template ROW}&lt;/pre&gt;&#xD;
&lt;p&gt;II: 使用*.Aspx搭建展示页面 &#xD;
  &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 主要代码&lt;/p&gt;&#xD;
&lt;pre &gt;&amp;lt;script src="&amp;lt;%=Url.Content("~/Scripts/jquery-jtemplates.js")%&amp;gt;" &#xD;
 type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;&#xD;
&#xD;
&amp;lt;script type="text/javascript"&amp;gt;&#xD;
$(document).ready(function () {		&#xD;
    $.ajax({&#xD;
	type:"POST",&#xD;
	url: "&amp;lt;%= Url.Action("GetData") %&amp;gt;",&#xD;
	data: "",&#xD;
	contentType: "application/json; charset=utf-8",&#xD;
	cache:false,&#xD;
	dataType: "json",&#xD;
	success: function(data){&#xD;
		if(data){&#xD;
			$("#jTemplateDemo").setTemplateURL("&amp;lt;%=Url.Action("GetTemplate")%&amp;gt;");						&#xD;
			$("#jTemplateDemo").processTemplate(data);	&#xD;
				&#xD;
		}&#xD;
	}&#xD;
    });    &#xD;
});&#xD;
		&#xD;
&amp;lt;/script&amp;gt;&#xD;
&#xD;
&amp;lt;div id="jTemplateDemo"&amp;gt;&amp;lt;/div&amp;gt;&lt;/pre&gt;&#xD;
&lt;p&gt;III:Action和Model &#xD;
  &lt;br /&gt;&amp;nbsp;&amp;nbsp; Action主要代码 &lt;/p&gt;&#xD;
&lt;pre &gt;public ActionResult Index(string id)&#xD;
{&#xD;
	return View();&#xD;
}&#xD;
/// &amp;lt;summary&amp;gt;&#xD;
/// Request for template content&#xD;
/// &amp;lt;/summary&amp;gt;&#xD;
/// &amp;lt;returns&amp;gt;templates&amp;lt;/returns&amp;gt;&#xD;
public ActionResult GetTemplate()&#xD;
{&#xD;
	return PartialView("TableTemp");&#xD;
}&#xD;
&#xD;
/// &amp;lt;summary&amp;gt;&#xD;
/// Request for temp data&#xD;
/// &amp;lt;/summary&amp;gt;&#xD;
/// &amp;lt;returns&amp;gt;temp data&amp;lt;/returns&amp;gt;&#xD;
[HttpPost]&#xD;
public ActionResult  GetData()&#xD;
{&#xD;
var model = new TempModel{&#xD;
	Name = "New Employees",&#xD;
	Peoples = new List&lt;person&gt;{&#xD;
		new Person {ID = "1", FirstName = "Anne", Email = "anne@domain.com",Age=20},&#xD;
		new Person {ID = "2", FirstName = "Amelie", Email = "amelie@domain.com",Age=22},&#xD;
		new Person {ID = "3", FirstName = "Polly", Email = "polly@domain.com",Age=35},&#xD;
		new Person {ID = "4", FirstName = "Alice", Email = "alice@domain.com",Age=27},&#xD;
		new Person {ID = "5", FirstName = "Martha", Email = "martha@domain.com",Age=32}&#xD;
	}&#xD;
};&#xD;
	return Json(model);&#xD;
}&lt;/person&gt;&lt;/pre&gt;&#xD;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; Model主要代码 &#xD;
&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;pre &gt;public class Person&#xD;
{&#xD;
	public string ID { get; set; }&#xD;
	public string FirstName { get; set; }&#xD;
	public string Email { get; set; }&#xD;
	public int Age { get; set; }&#xD;
}&#xD;
&#xD;
public class TempModel&#xD;
{&#xD;
	public string Name { get; set; }&#xD;
	public List&amp;lt;Person&amp;gt; Peoples { get; set; }&#xD;
&#xD;
}&lt;/pre&gt;&#xD;
&lt;p&gt;&lt;strong&gt;3 运行效果图&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;img src="http://public.blu.livefilestore.com/y1p1o54jz_UDm3vA3pCF4sg7M-Tt6go9OMExO4_jmjQIn3xAtKFbUEBodNjvAvXtt0za4paiXEV0pKu6AD0xf1e9Q/jtemplates-1-1.jpg" style="display: inline;" /&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/x116/aggbug/1757236.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/x116/archive/2010/06/12/1757236.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/x116/articles/1722685.html</id><title type="text">[摘抄]NHibernate: Nullable DateTime Issues</title><summary type="text">Url:http://ayende.com/Blog/archive/2007/03/26/NHibernate-Nullable-DateTime-Issues.aspxSystem.DateTime is a value type in .Net, which means that it can never be null. But what happens when you have a n...</summary><published>2010-04-28T02:00:00Z</published><updated>2010-04-28T02:00:00Z</updated><author><name>普若伽门</name><uri>http://www.cnblogs.com/x116/</uri></author><link rel="alternate" href="http://www.cnblogs.com/x116/articles/1722685.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/x116/articles/1722685.html"/><content type="html">&lt;p&gt;Url:&lt;a href="http://ayende.com/Blog/archive/2007/03/26/NHibernate-Nullable-DateTime-Issues.aspx" target="_blank"&gt;http://ayende.com/Blog/archive/2007/03/26/NHibernate-Nullable-DateTime-Issues.aspx&lt;/a&gt;&lt;/p&gt;&#xD;
&lt;p&gt;System.DateTime is a value type in .Net, which means that it can never be null. But what happens when you have a nullable date time in the database, and you load it into a DateTime type? &lt;/p&gt;&#xD;
&lt;p&gt;Consider this simple example. Mapping: &lt;/p&gt;&#xD;
&lt;div style="border-bottom: #999999 1px solid; border-left: #999999 1px solid; padding-bottom: 4px; background-color: #ffffe1; padding-left: 4px; width: 100%; padding-right: 4px; border-top: #999999 1px solid; border-right: #999999 1px solid; padding-top: 4px"&gt;&#xD;
&lt;p style="text-align: left; line-height: 150%; unicode-bidi: embed; direction: ltr;background: #ffffe1" dir="ltr"&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; font-size: 10pt"&gt;&amp;lt;&lt;span style="color: maroon"&gt;property&lt;/span&gt; &lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;="UpdatedDate" &lt;/span&gt;&lt;span style="color: red"&gt;nullable&lt;/span&gt;&lt;span style="color: blue"&gt;="True"&lt;/span&gt;&lt;span style="color: fuchsia"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: red"&gt;column&lt;/span&gt;&lt;span style="color: blue"&gt;="updated_date"&lt;/span&gt; &lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;="DateTime"&lt;/span&gt; &lt;span style="color: blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;/div&gt;&#xD;
&lt;p&gt;Property: &lt;/p&gt;&#xD;
&lt;div style="border-bottom: #999999 1px solid; border-left: #999999 1px solid; padding-bottom: 4px; background-color: #ffffe1; padding-left: 4px; width: 100%; padding-right: 4px; border-top: #999999 1px solid; border-right: #999999 1px solid; padding-top: 4px"&gt;&#xD;
&lt;p style="text-align: left; line-height: 150%; unicode-bidi: embed; direction: ltr;background: #ffffe1" dir="ltr"&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;public&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;&amp;nbsp;DateTime&amp;nbsp;UpdatedDate&amp;nbsp;&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;get&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;return&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;&amp;nbsp;m_dateTime;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;set&amp;nbsp;&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;{&amp;nbsp;m_DateTime&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;value&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;;&amp;nbsp;}&lt;br /&gt;}&lt;/span&gt; &lt;/p&gt;&lt;/div&gt;&#xD;
&lt;p&gt;When NHibernate loads a null value from the database, it cannot put a null in the UpdatedDate property, the CLR doesn't allow it. What happens is that the UpdatedDate property is set to the default DateTime value, in this case: 01/01/0001. &lt;/p&gt;&#xD;
&lt;p&gt;This can cause two major issues down the road. The first is that 01/01/0001 is not a valid date in SQL Server, so when you try to save the value, it will throw an exception. The second is that because of this issue, when NHibernate needs to track changes, it will check if null != 01/01/0001, and it will turn out that yes, this entity (which we never touched) &lt;em&gt;has&lt;/em&gt; changed. &lt;/p&gt;&#xD;
&lt;p&gt;This can cause an extra update (and thus an exception) which can cause some fairly significant head scratching. The solution is simple, you need to let NHibernate know what to do with null values. This can be done by simply using&amp;nbsp;a nullable type, such as: &lt;/p&gt;&#xD;
&lt;div style="border-bottom: #999999 1px solid; border-left: #999999 1px solid; padding-bottom: 4px; background-color: #ffffe1; padding-left: 4px; width: 100%; padding-right: 4px; border-top: #999999 1px solid; border-right: #999999 1px solid; padding-top: 4px"&gt;&#xD;
&lt;p style="text-align: left; line-height: 150%; unicode-bidi: embed; direction: ltr;background: #ffffe1" dir="ltr"&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;public&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;&amp;nbsp;DateTime?&amp;nbsp;UpdatedDate&amp;nbsp;&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;get&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;return&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;&amp;nbsp;m_dateTime;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;set&amp;nbsp;&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;{&amp;nbsp;m_DateTime&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;value&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;;&amp;nbsp;}&lt;br /&gt;}&lt;/span&gt; &lt;/p&gt;&lt;/div&gt;&#xD;
&lt;p&gt;&lt;span style="font-weight: normal"&gt;Or by using the Nullables.dll library for 1.1, and specifying the correct type in the mapping:&lt;/span&gt; &lt;/p&gt;&#xD;
&lt;div style="border-bottom: #999999 1px solid; border-left: #999999 1px solid; padding-bottom: 4px; background-color: #ffffe1; padding-left: 4px; width: 100%; padding-right: 4px; border-top: #999999 1px solid; border-right: #999999 1px solid; padding-top: 4px"&gt;&#xD;
&lt;p style="text-align: left; line-height: 150%; unicode-bidi: embed; direction: ltr;background: #ffffe1" dir="ltr"&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; font-size: 10pt"&gt;&amp;lt;&lt;span style="color: maroon"&gt;property&lt;/span&gt; &lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;="UpdatedDate" &lt;/span&gt;&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: red; font-size: 10pt"&gt;column&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;="updated_date"&lt;/span&gt; &lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: red; font-size: 10pt"&gt;type&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;="Nullables.&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;NHibernate&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;.NullableDateTimeType, Nullables.&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;NHibernate&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;"&lt;/span&gt; &lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;/&amp;gt;&lt;/span&gt; &lt;/p&gt;&lt;/div&gt;&#xD;
&lt;p&gt;With this property: &lt;/p&gt;&#xD;
&lt;div style="border-bottom: #999999 1px solid; border-left: #999999 1px solid; padding-bottom: 4px; background-color: #ffffe1; padding-left: 4px; width: 100%; padding-right: 4px; border-top: #999999 1px solid; border-right: #999999 1px solid; padding-top: 4px"&gt;&#xD;
&lt;p style="text-align: left; line-height: 150%; unicode-bidi: embed; direction: ltr;background: #ffffe1" dir="ltr"&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;public&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;&amp;nbsp;Nullables.NullableDateTime&amp;nbsp;UpdatedDate&amp;nbsp;&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;get&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;&amp;nbsp;{&amp;nbsp;&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;return&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;&amp;nbsp;m_dateTime;&amp;nbsp;}&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;&amp;nbsp;&amp;nbsp; set&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;&amp;nbsp;{&amp;nbsp;m_DateTime&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: blue; font-size: 10pt"&gt;value&lt;/span&gt;&lt;span style="line-height: 150%; font-family: 'Arial', 'sans-serif'; color: black; font-size: 10pt"&gt;;&amp;nbsp;}&lt;br /&gt;}&lt;/span&gt; &lt;/p&gt;&lt;/div&gt;&#xD;
&lt;p&gt;Thanks for &lt;span style="font-weight: normal"&gt;Sheraz Khan, for finding out and brining this to my attention, since then, I have run into the issue a couple of times, and I hope that if I blog about it, I will remember to match nullabilities.&lt;/span&gt; &lt;/p&gt;  &lt;img src="http://www.cnblogs.com/x116/aggbug/1722685.html?type=2" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/x116/articles/1722685.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/x116/articles/1540119.html</id><title type="text">身份证号码的规则及验证原理</title><summary type="text">【身份证号码的规则】1、15位身份证号码组成：ddddddyymmddxxs共15位，其中：dddddd为6位的地方代码，根据这6位可以获得该身份证号所在地。yy为2位的年份代码，是身份证持有人的出身年份。mm为2位的月份代码，是身份证持有人的出身月份。dd为2位的日期代码，是身份证持有人的出身日。这6位在一起组成了身份证持有人的出生日期。xx为2位的顺序码，这个是随机数。s为1位的性别代码，奇数...</summary><published>2009-08-06T02:28:00Z</published><updated>2009-08-06T02:28:00Z</updated><author><name>普若伽门</name><uri>http://www.cnblogs.com/x116/</uri></author><link rel="alternate" href="http://www.cnblogs.com/x116/articles/1540119.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/x116/articles/1540119.html"/></entry><entry><id>http://www.cnblogs.com/x116/articles/1459205.html</id><title type="text">[摘抄]领悟 JavaScript 中的面向对象</title><summary type="text">【搜自网络，还给网络】JavaScript 是面向对象的。但是不少人对这一点理解得并不全面。在 JavaScript 中，对象分为两种。一种可以称为&amp;#8220;普通对象&amp;#8221;，就是我们所普遍理解的那些：数字、日期、用户自定义的对象（如：{}）等等。还有一种，称为&amp;#8220;方法对象&amp;#8221;，就是我们通常定义的 function。你可能觉得奇怪：方法就是方法，怎么成了对象了？但是在...</summary><published>2009-05-18T03:00:00Z</published><updated>2009-05-18T03:00:00Z</updated><author><name>普若伽门</name><uri>http://www.cnblogs.com/x116/</uri></author><link rel="alternate" href="http://www.cnblogs.com/x116/articles/1459205.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/x116/articles/1459205.html"/></entry><entry><id>http://www.cnblogs.com/x116/articles/1454217.html</id><title type="text">Jquery 对 radio取值，checkbox取值，select取值，radio选中，checkbox选中，select选中等的精简操作</title><summary type="text">A 取值：1. 文本框 var value=$(&amp;quot;#textbox_id&amp;quot;).val();2. 单选框var value= $(&amp;quot;input[name=&amp;#39;sex&amp;#39;][checked]&amp;quot;).val(); 3. 下拉选择框 var value = $(&amp;quot;#select_id&amp;quot;).val();4.多选框 var value=$(&amp;quot;#checkbox_id&amp;quot;).attr(&amp;quot;value&amp;quot;);一组多选var str=&amp;quot;&amp;quot;;$(&amp;quot;input[name=&amp;#39;c</summary><published>2009-05-11T07:56:00Z</published><updated>2009-05-11T07:56:00Z</updated><author><name>普若伽门</name><uri>http://www.cnblogs.com/x116/</uri></author><link rel="alternate" href="http://www.cnblogs.com/x116/articles/1454217.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/x116/articles/1454217.html"/></entry><entry><id>http://www.cnblogs.com/x116/articles/1384416.html</id><title type="text">为非回调页面保存状态</title><summary type="text"/><published>2009-02-05T03:27:00Z</published><updated>2009-02-05T03:27:00Z</updated><author><name>普若伽门</name><uri>http://www.cnblogs.com/x116/</uri></author><link rel="alternate" href="http://www.cnblogs.com/x116/articles/1384416.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/x116/articles/1384416.html"/></entry><entry><id>http://www.cnblogs.com/x116/archive/2009/02/03/1378548.html</id><title type="text">WEB应用程序的快捷键简单设计</title><summary type="text">&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;在WEB APP 里，经常考虑到某种功能使用快捷键，可是组合快捷键和F1-F12等功能键又不能直接定义使用，怎么办呢？&amp;#160;&amp;#160; &amp;#160; 有一些简单办法可以做到使用快捷键而不必要大费周章，&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1。 需要使...</summary><published>2009-02-03T03:28:00Z</published><updated>2009-02-03T03:28:00Z</updated><author><name>普若伽门</name><uri>http://www.cnblogs.com/x116/</uri></author><link rel="alternate" href="http://www.cnblogs.com/x116/archive/2009/02/03/1378548.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/x116/archive/2009/02/03/1378548.html"/></entry></feed>
