Sitecore 快速查询出现解析异常
为什么我会收到以下代码的错误 ParseException: End of string Expected atposition 4.
代码如下:错误位于第 3 行。
var db = Sitecore.Configuration.Factory.GetDatabase("web");
string query = @"fast:/sitecore/content/foodservice/home/Products/3492-5326/3518-7";
Item item = db.SelectSingleItem(query);
return item;
我们可以使用 进行快速查询吗?代码>SelectSingleItem()?我试图避免
获取文件夹内容并循环遍历每个项目,直到找到目标解决方案。
建议?
Why am I getting this error with the code below ParseException: End of string expected at position 4.
Here's the code: The error is on the 3rd line.
var db = Sitecore.Configuration.Factory.GetDatabase("web");
string query = @"fast:/sitecore/content/foodservice/home/Products/3492-5326/3518-7";
Item item = db.SelectSingleItem(query);
return item;
Can we use a fast query with SelectSingleItem()
? I was trying to avoid the get folder contents and loop through each item until I find the target solution.
Suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 Sitecore 查询时,您需要使用破折号转义项目名称。来自 SDN:
更新:
我已经确认这也适用于快速查询。
相同的代码在 #escapes# 下运行良好:
When using Sitecore Query, you need to escape item names with dashes. From SDN:
UPDATE:
I have confirmed that this applies to Fast Query as well.
The same code runs fine with #escapes#:
这是使用 Fast Query 和 SelectSingleItem() 时的一个错误。该问题已在 Sitecore CMS 6.3.0 rev.100716 版本中修复。请参阅发行说明。由于我们使用的是 6.2,我必须重写我的方法以使用 Sitecore 查询而不是快速查询。
This is a bug when using Fast Query and SelectSingleItem(). The issue is fixed in the Sitecore CMS 6.3.0 rev.100716 release. See Release Notes. Since we are using 6.2, I had to rewrite my method to use a Sitecore Query instead of the Fast Query.