How can I combine sequential expression trees into a fast method?
        Posted  
        
            by chillitom
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by chillitom
        
        
        
        Published on 2010-03-10T17:24:10Z
        Indexed on 
            2010/03/14
            9:55 UTC
        
        
        Read the original article
        Hit count: 445
        
Suppose I have the following expressions:
Expression<Action<T, StringBuilder>> expr1 = (t, sb) => sb.Append(t.Name);
Expression<Action<T, StringBuilder>> expr2 = (t, sb) => sb.Append(", ");
Expression<Action<T, StringBuilder>> expr3 = (t, sb) => sb.Append(t.Description);
I'd like to be able to compile these into a method/delegate equivalent to the following:
void Method(T t, StringBuilder sb) 
{
    sb.Append(t.Name);
    sb.Append(", ");
    sb.Append(t.Description);
}
What is the best way to approach this? I'd like it to perform well, ideally with performance equivalent to the above method.
© Stack Overflow or respective owner