映射表达式< Func< Type1,bool>>表达式< Func< Type2,bool> [英] Mapping Expression<Func<Type1,bool>> Expression<Func<Type2, bool>>

查看:93
本文介绍了映射表达式< Func< Type1,bool>>表达式< Func< Type2,bool>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将查询从业务层传递到服务层,但是在执行此操作时,我必须将DTO转换为实体模型.

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.

通常我可以通过Autommaper将Type1转换为Type2,但是现在我想映射 Expression<Func<Type1,bool>>Expression<Func<Type2, bool>>

Normally i can convert Type1 to Type2 via Autommaper but now i want to map Expression<Func<Type1,bool>> to Expression<Func<Type2, bool>>

我从Automapper中收到错误消息

I got error from Automapper

Missing type map configuration or unsupported mapping. 
Mapping types: Expression`1 -> Expression`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

关于您在上面发布的错误,这似乎是因为您尝试使用AutoMapper将一种Expression类型映射到另一种Expression类型,例如Mapper.Map<Expression<Func<Type1,bool>>, Expression<Func<Type2, bool>>>(exp1, exp2).这种事情是不被支持的. AutoMapper仅适用于不同类型的实例之间的映射,不适用于处理这些类型的表达式.

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.

这篇关于映射表达式&lt; Func&lt; Type1,bool&gt;&gt;表达式&lt; Func&lt; Type2,bool&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆