I\'ve started to use https://github.com/robconery/massive for a project, I wonder if there is any mapping tool that allows support for Dynamic to static type mapping?
Try Slapper.AutoMapper https://github.com/randyburden/Slapper.AutoMapper
Slapper.AutoMapper maps dynamic data to static types
It works for both dynamic and Dictionary which is awesome.
Here's an example (taken from the URL above) showing how easily it works with Dictionary:
public class Person
{
public int Id;
public string FirstName;
public string LastName;
}
[Test]
public void CanMapMatchingFieldNamesWithEase()
{
// Arrange
var dictionary = new Dictionary
{
{ "Id", 1 },
{ "FirstName", "Clark" },
{ "LastName", "Kent" }
};
// Act
var person = Slapper.AutoMapper.Map( dictionary );
// Assert
Assert.NotNull( person );
Assert.That( person.Id == 1 );
Assert.That( person.FirstName == "Clark" );
Assert.That( person.LastName == "Kent" );
}