So... for a CSV export from a SQL Server database, using C# and Entity Framework, I need to get the raw value of HierarchyId
.
The raw value looks like that in SSMS: 0x29F9DC
and the output in my CSV is like that: /-25/-5/
.
The CSV is generated using a StringBuilder
, each line of my entity is transform via a ToCsv
method:
return IdClassificationEc + ";" + Libelle + ";" + Complement;
where IdclassificationEc
is a hierarchyId
.
With or without a ToString
, I get the readable value and there is no known way to get the raw, hex, value.
Using T-SQL, I was able to get the good value on a string using this:
CONVERT(VARCHAR, CAST(evc.ID_CLASSIFICATION_EC AS VARBINARY), 1)
Please, help me with this frustrating issue :'(