Profile

Click to view full profile
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time. Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more...

Saturday, July 30, 2011

DataContext vs ItemsSource (in Binding case)

Great article: DataContext vs ItemsSource (in Binding case)
The difference is that when using DataContext, it means that you bind the owner object of DataContext with the reference, which is DataContext pointed to. So, it some cases such as DataGrid or ListBox. We use ItemSource instead when we're talking about data in each row, not the DataGrid itself. On the other hand, we use DataContext to set binding from source ojbect to DataGrid directly.

Thursday, July 28, 2011

How to pass Dynamic Anonymous Object to ViewPage in Razor

Normally, you can't pass anonymous object as a model to ViewPage because it can only be accessed from within the assembly in which it’s declared. Since views get compiled separately, the dynamic binder complains that it can’t go over that assembly boundary. So, to solve this problem we have to create own ViewPage that use dynamic object as a Model, or create extension method to change its type to ExpandoObject.

Using ExpandoObject:
public static ExpandoObject ToExpando(this object anonymousObject)
{
    IDictionary anonymousDictionary =
    HtmlHelper.AnonymousObjectToHtmlAttributes(anonymousObject);
    IDictionary expando = new ExpandoObject();
    foreach (var item in anonymousDictionary)
        expando.Add(item);
    return (ExpandoObject)expando;
}

Then, you can pass anonymous object through Model, and use it as dynamic object.
References: http://stackoverflow.com/questions/5120317/dynamic-anonymous-type-in-razor-causes-runtimebinderexception, http://blogs.msdn.com/b/davidebb/archive/2009/12/18/passing-anonymous-objects-to-mvc-views-and-accessing-them-using-dynamic.aspx

Wednesday, July 27, 2011

Comparison of NoSQL

Nowadays, there are many NoSQL tools or engines to use. Some people may not know which one should be used. Let's see the NoSQL comparison to know their strength and weakness here: http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis. If you don't know what NoSQL is, take a look here: http://en.wikipedia.org/wiki/NoSQL.

Wednesday, June 22, 2011

Did you meant to say/did you mean to say

It must be "Did you mean to say" because meant is a past participle form of mean and did shows that this sentence is in the past.
Credit: http://www.englishforums.com/English/DidMeantMeanSay/ddkbn/post.htm

Sunday, June 19, 2011

Lets vs let's

To let means to "allow".

Let him in. = Allow him to come in.

The word "let's" means "let us"

The first comes with the pronoun "us".
The second does not come with the pronoun "us".


She lets [allows] him to paint. = She allows him to paint.

So the rule is that when you mean let us, or allow us, or permits us, you use let's.

The following examples do not have the plural pronoun [us] contraction so no apostrophy is used.

She lets me paint. = She allows me to paint.
She lets them paint. = She allows them to paint.
She lets him or her paint. She allows him or her to paint.

Credit: http://www.englishforums.com/English/LetsVsLets/gnbh/post.htm from 
Radrook