Reputation: 1842
I need to use emitmapper with diffirent types. For defoult it takes two generic types:
ObjectMapperManager.DefaultInstance.GetMapper<TSource, TEntity>().Map(source, result);
I need do something like this:
class Result { public string Name { set; get;} public int Age {set; get;} }
...
Result result;
object someType = new SomeTypes { Name = "TestName", Age = 23 }
ObjectMapperManager.DefaultInstance.GetMapper<object, Result >().Map(source, result);
Console.WriteLine(result.Name);
Upvotes: 1
Views: 911
Reputation: 17377
AFAIK you can't do this with EmitMapper. You could with AutoMapper. The feature is dynamic mapping:
object someType = new SomeTypes { Name = "TestName", Age = 23 }
var result = Mapper.DynamicMap<Result>(someType);
Upvotes: 1