Skip to content

Instantly share code, notes, and snippets.

@schotime
Created January 10, 2011 21:18
Show Gist options
  • Save schotime/773490 to your computer and use it in GitHub Desktop.
Save schotime/773490 to your computer and use it in GitHub Desktop.
//Mappings
CreateMap<DateTime, FormattedDateTime>().ConvertUsing<FormattedDateConverter>();
CreateMap<string, bool>().ConvertUsing(x => x == "Y" || x.ToLowerInvariant() == "on" || x == "1");
//Dictionary
var dict = new Dictionary<string,object>() { { "id", 2 },{ "date", DateTime.Now }, { "istrue", "Y" } };
//Class
public class DisplayDate {
public int id { get;set; }
public FormattedDateTime date { get; set; }
public bool istrue { get; set;}
}
//Actual Mapping
var dispdate = Mapper.Map<IDictionary<string,object>, DispalyDate>(dict);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment