Mapping Expression<Func<Type1,bool>> Expression<Func<Type2, bool>>

社会主义新天地 提交于 2019-12-07 23:00:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!