Sitecore的:选择通过现场项目:TreelistEx [英] Sitecore: select items by field: TreelistEx
问题描述
我有型MyItem的项目Sitecore的文件夹命名为MyItems。我需要查询从.NET code无论是与Sitecore的查询或使用XPath的项目。 MyItem有型TreelistEx领域MyField的。我需要选择,其中包含MyField的thevalue(GUID其他项目)的所有项目。我该怎么办呢?
非常感谢
查询字符串=的String.Format(/ Sitecore的/内容/ MyItems / * [包含(@MyField,'{ 0}')],thevalue);
项目[] = myItems Sitecore.Context.Database.SelectItems(查询);
我刚拔掉这个code从我的网站和调整您的查询的名称。这是相当低效的,如果你有很多MyItems的,所以我不会一个网页,性能是关键上使用此。同样的查询应该适用于任何列表类型字段。
I have Sitecore folder named MyItems with items of type MyItem. I need to query the items from .net code either with sitecore query or with xpath. MyItem has field MyField of type TreelistEx. I need to select all items where MyField contains 'thevalue' (guid of other item). How can i do it?
Thanks a lot
string query = string.Format("/sitecore/content/MyItems/*[contains(@MyField,'{0}')]", thevalue);
Item[] myItems = Sitecore.Context.Database.SelectItems(query);
I just pulled this code from my site and adjusted the names for your query. It is fairly inefficient if you have a lot of MyItems, so I wouldn't use this on a page where performance is key. The same query should work for any list-type field.
这篇关于Sitecore的:选择通过现场项目:TreelistEx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!