ListItem query with Fluent API in multilingual site
Hi
I have a list who's content is available in 5 languages.
Due to the built in Sitefinty list control being far from accessible I'm writing my own control, the query to retrieve the items is as follows:
var listItems = fluentApi.ListItems().
Where(li => li.Parent.Title == ListName).
Publihed().
Get();
This works fine on the English version however I need to get the other language versions depending on which language version of the site is being browsed. It appears as though the AvailableCultures collection should give me this, and thought I could just check against the current culture however when I try this I get an error stating this has not been implemented server side.
Could you advise on how this can be achieved?
Thanks
Hi,
I'm getting the same problem, but for blogs. Did you find a solution?
How to query by a localized property?
Thanks
Hi Stefano,
You can query localized items as follows ( example is for news items ):
var currentCulture = Thread.CurrentThread.CurrentUICulture.Name;
NewsManager nm = NewsManager.GetManager();
var newsItems = nm.GetNewsItems().Where(d => d.Status == ContentLifecycleStatus.Live).ToList();
var items = newsItems.Where(d => d.AvailableCultures.Contains(
new
CultureInfo(currentCulture))).ToList();