2

I need to extract an item with Glassmapper in specific language. But in Glassmapper 5 this method is marked as "Obsolete":

 _sitecoreService.GetItem<IAvailableCountries>
                (Models.Constants.Items.CountryTagFolder, LanguageManager.GetLanguage("en"));

enter image description here

But I don`t see any overloaded version of GetItem where I can pass language as parameter.

What is the best practice to do it with Glassmapper 5?

1 Answer 1

6

You should use now either GetItemByIdOptions or GetItemByPathOptions (or other options) and pass language there, e.g.:

var options = new GetItemByIdOptions(guid) { Language = language };
var item = sitecoreService.GetItem<IAvailableCountries>(options);

Read more here:

https://blogs.perficient.com/2018/10/29/glass-mapper-part-2-of-2-what-is-new-and-changed-in-version-5/

1
  • Thank you! Exactly that I found.
    – x3mxray
    Mar 27, 2020 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.