I have 2 extension methods that convert a MongoDB document to an entity/object.
public static ProductTemplate Convert(this Document document)
{
return null;
}
public static Product Convert(this Document document)
{
return null;
}
This gives an expected ambiguous call error so I was wondering how I could fix this?
Friendly greetings,
Pickels
Functions can’t be overloaded by return type. You will have to rename your functions to maybe:
ConvertToProductTemplate()
and
ConvertToProduct()
or turn them into one function which returns a common base class or interface. (But then the caller will have to do a cast when they get your result)