I have searched and cannot find a way to do this. Seems like it should be similar to geography and geometry but that does not work.
At long last and with help from chatai this seems to work
string connectionString = "Data Source=MTGLaptop\SQL2022;Initial Catalog=AdventureWorks2022;Integrated Security=True;";
string query = "SELECT TOP 5 DocumentNode FROM Production.Document;";
using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString))
{ System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(query, connection);
connection.Open();
using (System.Data.SqlClient.SqlDataReader reader = command.ExecuteReader())
{ while (reader.Read())
{ System.Data.SqlTypes.SqlBinary SqlBinary = reader.GetSqlBinary(0);
Microsoft.SqlServer.Types.SqlHierarchyId SqlHierarchyId = SqlHierarchyId.Null;
SqlHierarchyId.Read(new BinaryReader(new MemoryStream((byte)SqlBinary.Value)));
}
}
}