List title not set in lamda expression when multiple languag

Posted by Community Admin on 04-Aug-2018 16:31

List title not set in lamda expression when multiple languages turned on

All Replies

Posted by Community Admin on 06-May-2011 00:00

I am pulling list items through code in a custom control.  Before I added a new language I was able to access the items I needed through the following code:

var items = lm.GetListItems()
            .Where(li => li.Parent.Title == "Home Page Slides");

When I added the new language, this call didn't return any items.  After a little bit of testing I discovered that the Parent's title isn't set yet for some reason.  Using the following code gave me every list item:

var items = lm.GetListItems()
            .Where(li => String.IsNullOrEmpty(li.Parent.Title));

Though even when looping through the list right after the call, I was able to output the title as expected:

foreach (Telerik.Sitefinity.Lists.Model.ListItem li in items)
            Response.Write("ITEM TITLE: " + li.Title + " PARENT TITLE: " + li.Parent.Title + "<BR>");
        


Obviously the work around would be to just loop through the item list after the fact and filter them based on the parent's title, but this is very odd bug and I imagine it will affect other places in my site where I am using similar methods.

Posted by Community Admin on 11-May-2011 00:00

Hello Michael,

Thank you for contacting us!

This is known issue and it is fixed. It will be released within the upcoming Service Pack(e.g. SP1), which will be available till begin of the next week.

There is also workaround in case you are not planning to update your installation to SP1. Lets assumed that there are two applied languages in given Sitefinity's installation: English([en]   -> which is default for the system) and French([fr]). In such case you should write your filter expression like this:

lm.GetItems(typeof(Telerik.Sitefinity.Lists.Model.ListItem), "Title.Contains(\"Home Page Slides\") OR (Title[\"en\"] = null AND Title[\"fr\"] = null AND Title[\"\"].Contains(\"Home Page Slides\"))", string.Empty, 0, 100);

*Please note you should check if Title is null for every other language,which was added within the Sitefinity's installation(e.g OR.Title[\"it\"] = null in case there is Italian language)

Kind regards,
Tihomir
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed