質問

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