Вопрос

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);
Это было полезно?

Решение

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);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top