I'm trying to understand the logic behind Related Documents in CMSDesk.
Let's say I've got a document ('docA'), and I've used the CMSDesk to relate it to another document ('docB').
Now I want to list all related documents when 'docA' is rendered.
In my code, I tried using what I thought was the obvious choice:
CMSContext.CurrentDocument.RelatedDocuments
I figured this would contain a collection of related documents, and that I could use standard array selectors to select my related documents. E.g.:
CMSContext.CurrentDocument.RelatedDocuments[0]
I was wrong. The above code returns NULL every time. And this:
CMSContext.CurrentDocument.RelatedDocuments.Count
Always returns '0' (zero).
*BUT*, the following code returns a value:
CMSContext.CurrentDocument.RelatedDocuments.FirstOrDefault()
Why would this work, but not the previous line of code. It means that to select the first related document, I have to use the following code:
CMSContext.CurrentDocument.RelatedDocuments.FirstOrDefault()[0]
This seems weird and dumb to me.
Can someone explain why CMSContext.CurrentDocument.RelatedDocuments hasn't simply been implemented as a standard list? What is the logic behind all this?
Thanks.