Skip to content

Instantly share code, notes, and snippets.

@ahmad2x4
Created September 28, 2014 00:49
Show Gist options
  • Save ahmad2x4/8f586c3e08a799ef792a to your computer and use it in GitHub Desktop.
Save ahmad2x4/8f586c3e08a799ef792a to your computer and use it in GitHub Desktop.
Blog automapper extensions
public static class FunctionCompositionExtensions
{
public static Expression<Func<TX, TY>> Compose<TX, TY, TZ>(this Expression<Func<TZ, TY>> outer, Expression<Func<TX, TZ>> inner)
{
return Expression.Lambda<Func<TX, TY>>(
ParameterReplacer.Replace(outer.Body, outer.Parameters[0], inner.Body),
inner.Parameters[0]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment