Reputation: 1043
I am using the below scripting functoid in the biztalk map to convert the string in to dateTime
public DateTime? ConvertOpenDate(string openDate)
{
DateTime oDate;
if (!DateTime.TryParseExact(openDate, "yyyy-MM-DD HH:mm:ss.fff", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out oDate))
{
return null;
}
else
{
return oDate;
}
}
But it is throwing error saying
Extension functions cannot return null values.
How to handle this. I am inserting the datetime in to MS SQL DB
Upvotes: 2
Views: 3291
Reputation: 366
A solution would be to prevent a null value to be mapped as input of your functoid. This can be achieved by combining a LogicalExistence and Value mapping functoid (for delimited files) or IsNil and value mapping functoid (for positional files, because whitespaces are considered "existing" in that kind of files).
Upvotes: 0
Reputation: 100517
This is known behavior: Known issues in BizTalk Server 2013 with resolution "Return String.Empty or some other alternative value to represent the null scenario".
Returning null is not supported
Symptom
When you return a null value from a functoid, the map fails and you receive the following generic error message...When you test the same map in Visual Studio, it provides a more descriptive error message:
Exception has been thrown by the target of an invocation. Extension functions cannot return null values.Note The XslCompiledTransform class does not support returning null values from functions that are called within the transform.
Resolution
Return String.Empty or some other alternative value to represent the null scenario. If it is needed, use a global variable to make the null value available across multiple functions.
Upvotes: 5