문제

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