From c3420f8dd668d313ac33caa6544ae4aa7f587216 Mon Sep 17 00:00:00 2001 From: Isaac Breuer Date: Mon, 26 May 2025 13:18:10 -0400 Subject: [PATCH] Update wwDotnetBridge.PRG Added support for handling empty date and datetime fields Added support for handling empty date and datetime fields If the Cursor contains empty date values, the corresponding XSD must include nillable="true". Additionally, empty date/datetime tags should be removed from the XML to avoid errors when calling DataSet.ReadXml() in .NET. --- Distribution/wwDotnetBridge.PRG | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Distribution/wwDotnetBridge.PRG b/Distribution/wwDotnetBridge.PRG index 92e1af2..3165105 100644 --- a/Distribution/wwDotnetBridge.PRG +++ b/Distribution/wwDotnetBridge.PRG @@ -1225,7 +1225,7 @@ ENDFUNC *** the data *** Return: DataSet or NULL ************************************************************************ -FUNCTION CursorToDataSet(lcAliasList) +FUNCTION CursorToDataSet(lcAliasList,fixemptydates) LOCAL lnX, lcXml IF EMPTY(lcAliasList) @@ -1253,6 +1253,20 @@ IF EMPTY(lcXml) RETURN null ENDIF +IF fixemptydates +* add nillable=true to xds part of xml for date and Datetime fileds +lcXml= STRTRAN(lcXml,'type="xsd:date"' ,'type="xsd:date" nillable="true"') && dates +lcXml= STRTRAN(lcXml,'type="xsd:dateTime"' ,'type="xsd:dateTime" nillable="true"') &&dateTime +*delete all self closeing tags for date fileds from the xml +FOR lnX = 1 TO lnCount && loop lcAliasList +FOR Lnxfldloop = 1 TO AFIELDS(afldsarr,laCursors[lnX]) && loop Fields +IF INLIST(afldsarr(Lnxfldloop ,2),"D","T") +lcXml= STRTRAN(lcXml, '<'+LOWER(afldsarr(Lnxfldloop ,1) )+'/>' ,'') +endif +endfor +ENDFOR +ENDIF + RETURN THIS.XmlStringToDataSet(lcXml) ENDFUNC * CursorToDataSet @@ -2165,4 +2179,4 @@ ENDFUNC ************************************************************************ FUNCTION InitializeDotnetCoreVersion(lcVersion) RETURN GetwwDotnetCoreBridge(lcVersion) -ENDFUNC \ No newline at end of file +ENDFUNC