Issue with getting database via Sitecore API

i’ve spend the last couple hours trying to figure out what’s wrong with my code. I was trying something simple, getting an item from the Sitecore Web database. Which turns out not so simple after all, frequently i cannot retrieve any field values from the item that i retrieved.

After a long time trying out different things, renaming the section, rename the item name, change the template, change the content tree structure, checkout if any custom pipeline might be the isssue…

It turns out that this line of code -which looks ok at first glance- has an issue

in other area of the software that we develop we were using this code to get the database instead

it turns out that those two ways of getting the database instance is totally different from what i originally thought.

By using the constructor approach we only create an empty database object while using the latter approach it will build the database instance with all of the configuration values within the config file via reflection.

thanks to this Stackoverflow post my misery has ended.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.