Created
May 9, 2013 16:49
-
-
Save ashutoshraina/5548741 to your computer and use it in GitHub Desktop.
ToExpando() for working with Anonymous Objects with Razor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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