问题
I want to pass my query from Business Layer to Service Layer but when doing this i have to convert my DTO to Entity model.
Normally i can convert Type1 to Type2 via Autommaper but now i want to map
Expression<Func<Type1,bool>>
to Expression<Func<Type2, bool>>
I got error from Automapper
Missing type map configuration or unsupported mapping.
Mapping types: Expression`1 -> Expression`1
How can i achieve this?
回答1:
I just updated my answer to the another question you commented on, which I think addresses this: AutoMapper for Func's between selector types
As for the error you posted above, that appears to be because you tried to map one Expression type to another with AutoMapper, e.g. Mapper.Map<Expression<Func<Type1,bool>>, Expression<Func<Type2, bool>>>(exp1, exp2)
. That sort of thing is not supported; AutoMapper is only for mapping between instances of different types, not expressions that deal with those types.
Anyway, if you read my other answer it may tell you how to achieve what you want.
来源:https://stackoverflow.com/questions/15724038/mapping-expressionfunctype1-bool-expressionfunctype2-bool