CreateMap
Mapper.CreateMap<Unidade, unidadeDTO>();
Mapper.CreateMap<unidadeDTO, Unidade>();
public ICollection<Unidade> BuscarPorParametos(Expression<Func<Unidade, bool>> parametros)
{
return Mapper.Map<ICollection<unidadeDTO>, ICollection<Unidade>>(unidadeDeTrabalho.UnidadeDAO.BuscarPorParametros(Mapper.Map<Expression<Func<Unidade, bool>>, Expression<Func<unidadeDTO, bool>>>(parametros)));
}
Automapper exception:
Missing type map configuration or unsupported mapping.
Mapping types: Expression
1 -> Expression
1 System.Linq.Expressions.Expression1[[System.Func
2[[Unidade, Dominio, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] -> System.Linq.Expressions.Expression1[[System.Func
2[[unidadeDTO, Infraestrutura, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]Destination path: Expression`1
Source value: p => ((p.CodUnidade == 1) AndAlso (p.CodTrabalho == 1))
Expression
s. You normally use the expressions as part of queries, then automap the results of those queries to different classes. – Tim S.CreateMap
statements? – Gert ArnoldMapper.Map
statement? Right now, you're trying to copy an expression to another expression, but you clearly don't intend to do that (and it's impossible). – Gert Arnold