Question

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);
Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top