Archive for July 2010
Khmer Collation support in SQL Server 2008
SQL Server ’08 using default collation as “SQL_Latin1_General_CP1_CI_AS” which most/all of us knew that
- We can store Khmer Unicode (with NVARCHAR, NText etc)
- Searching Khmer Unicode ? suck !
There are work around if you really want to search content in Khmer Unicode after you stored it; using SQL Server ’08 default collation. How?
Method #1: Try to break each word using hidden space
Method #2: Encoding incoming Khmer Unicode content and stored it as ASCI
It works but it hurt; there is an althernative SQL Server ’08 introduce a few additional collation algorithm among those “Khmer_100″ is one of them.
That awesome all you have to do is changing your column collation from <default collation> to “Windows Collation -> Khmer_100″ that’s it no code isn’t that cool ?
No it’s not cool, It only works if SQL Server install on Windows Vista or Higher.
Edit: actually we can also use this
Mocking ASP.NET MVC 2 Context & Session using RhinoMock
Watching video record from #mvcconf about “Making ASP.NET Apps Testable” by Eric B. Sowell. He showing how to test ASP.NET MVC Session make me wonder how difficult it is for RhinoMock so I load sample app and here how I test it. Since
[Test]
public void TestSession()
{
// Arrange
// HttpContextBase, HttpSessionStateBase are abstract classes
// I can ask RhinoMock to generate stubs for those classes
var httpContext = MockRepository.GenerateStub<HttpContextBase>();
var session = MockRepository.GenerateStub<HttpSessionStateBase>();
session["Name"] = "Sokun";
httpContext.Stub(c => c.Session)
.Return(session);
// act
controller.ControllerContext = new ControllerContext(httpContext, new RouteData(), controller);
var result = controller.TestSession() as ViewResult;
// assert
Assert.IsNotNull(result);
}
and the action:
public ActionResult TestSession()
{
ViewData["Name"] = Session["Name"];
return View();
}
So, what you think? it just fine to love ASP.NET MVC 2
Me & the Onion Architecture
Jump into ASP.NET MVC 2 in Action Chapter 23 which talk about an integration of ASP.NET MVC and NHibernate the author introduce us to the Onion Architecture.

Using this architecture we simply structure our solution like:
- Core, storing POCO & various Interfaces
- Infrastructure, talking with underline or external system
- IntegrationTests, generally speaking this would test Infrastructure functionality
- UI
Let focus on the Infrastructure because it is the main actor in this architecture; the following role given to this layer
- Mapping between Core class & Database by talking through NHibernate (I agree)
- Responsible for injecting NHibernate session into web session with NHibernateModule: IHttpModule (I agree)
- Contain abstract RepositoryBase<T>: IRepository<T> (I agree)
- Contain all Interfaces implmentation hmm ? isn’t it too much for an Infrastructure? what about
- Core
- Infrastructure
- Services
- IntegrationTests
- UI
I will do more investigation (Pros, Cons) but love to hear your take on this, if you haven’t read the chapter yet do it now.


