Skip to content

Instantly share code, notes, and snippets.

@ashutoshraina
Created May 9, 2013 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashutoshraina/5548741 to your computer and use it in GitHub Desktop.
Save ashutoshraina/5548741 to your computer and use it in GitHub Desktop.
ToExpando() for working with Anonymous Objects with Razor.
public static ExpandoObject ToExpando(this object anonymousObject)
{
IDictionary<string, object> anonymousDictionary = new RouteValueDictionary(anonymousObject);
IDictionary<string, object> expando = new ExpandoObject();
foreach (var item in anonymousDictionary)
expando.Add(item);
return (ExpandoObject) expando;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment