AutoMapper and reflection -
my shared hosting company doesn't allow reflection. how can use automapper?
do have specify each property .formember?
mapper.createmap<person, persondata>() .formember(dest => dest.name, o => o.mapfrom(src => src.name)) .formember(dest => dest.address, o => o.mapfrom(src => src.address));
thanks,
filip
automapper uses reflection.emit
, sure can use automapper?
[edit]
dont know of uses without reflection, 1 had created xmldatamapper on codeplex uses reflection. difficult design 1 without reflection or reflection.emit
the simplest , basic way this, can use of 2 or both techniques.
public class conversionhelper { public static classb convert(classa item) { return new classb() { id = item.id, name = item.name }; } public static list<classb> convert(list<classa> list) { return list.select(o => new classb() { id = o.id, name = o.name }).tolist(); } } public class classa { public int id { get; set; } public string name { get; set; } } public class classb { public int id { get; set; } public string name { get; set; } }
from sample have given anyways trying map property 1 one, on same lines, lesser code.
Comments
Post a Comment