ToDictionary
Contents |
Namespace
Summary
Sends the properties/values of an object to a Dictionary<string,object>.
Example
Dictionary<string,object> objectValues=myObject.ToDictionary();
Unit Test
public void ToDictionary_Should_Return_5_Items_For_Test_Object() { var tester = new { thing1 = "test", thing2 = DateTime.Now, thing3 = 1, thing4 = 2.03M, thing5 = Guid.NewGuid() }; var result = tester.ToDictionary(); Assert.Equal(5, result.Count); }
Comments
SubSonic 3.0 implements this as an extension method - 2.x uses a static method on SubSonic.Sugar.Numeric.