EntityTranslatorService suggested change

Topics: CAB & Smart Client Software Factory
Aug 5, 2006 at 2:29 PM
originally posted by: GregShaw

The Service Agent recipe now uses the EntityTranslatorService. Problem is if the type that you are translating from is the same as the type you are translating to and you have not provided a translation you get an exception.
Can I suggest adding the following:
if (sourceType.Equals(targetType))
return source;
After the line:
Type sourceType = source.GetType();
In the recipe that generates the code for EntityTranslatorService:
EntityTranslatorService::Translate(Type targetType, object source)

It has fixed my problem.

Cheers, Greg.