C#使用泛型类型“ObjectMapper<TSource,TDestination>”需要两个类型参数

var body2 = ObjectMapper.Map<CreateUpdateReportReceiveDataInDto, CreateUpdateReportReceiveDataInBaseDto>(body);
使用泛型类型“ObjectMapper<TSource,TDestination>”需要两个类型参数

这个错误通常是由于没有正确指定泛型类型参数引起的。根据您提供的代码片段,似乎您正在尝试使用一个泛型类型ObjectMapper<TSource, TDestination>,但是没有指定类型参数。您需要将<CreateUpdateReportReceiveDataInDto, CreateUpdateReportReceiveDataInBaseDto>作为类型参数传递给ObjectMapper,如下所示:

var body2 = ObjectMapper.Map<CreateUpdateReportReceiveDataInDto, CreateUpdateReportReceiveDataInBaseDto>(body);

这样做可以告诉编译器使用CreateUpdateReportReceiveDataInDto类型作为源类型参数,使用CreateUpdateReportReceiveDataInBaseDto类型作为目标类型参数来实例化泛型类型ObjectMapper<TSource, TDestination>。这样就可以避免编译错误。