“System.Reflection.AmbiguousMatchException”类型的异常在 mscorlib.dll 中发生

错误提示:

“System.Reflection.AmbiguousMatchException”类型的异常在 mscorlib.dll 中发生,但未在用户代码中进行处理。 发现不明确的匹配。

问题原由:

1)因为自己写DTO类继承了EntityDto<long>,且含有以下Id属性 。

public new long Id { get; set; }

2)在转化时有两个Id,JSON.EncodeToEntity不知道该如何匹配。

处理结果:

自己写的DTO类不需要继承EntityDto<long> ,直接声明Id属性即可。

如果继承了EntityDto<long> 则在进行json字符串往对象转换时(本项目中通过方法JSON.EncodeToEntity进行转化)出现此报错。

原文地址:https://www.cnblogs.com/senyier/p/7298759.html