为什么我使用下面的代码收到此错误 ParseException: End of string expected at position 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;
Run Code Online (Sandbox Code Playgroud)
我们可以使用快速查询SelectSingleItem()吗?我试图避免这些get folder contents and loop through each item until I find the target solution.建议?
tec*_*414 17
使用Sitecore Query时,您需要使用破折号转义项目名称.来自SDN:
名称中带破折号的项目(" - ")应包含在"#"符号中.请使用以下语法:/ sitecore/content/Home /#About-us#.否则,您可能会收到以下错误:无效的查找源"/ sitecore/content/TestSiteB/Home/About-us":位于第38位的字符串结尾.此外,如果项目名称包含在"#"符号中"和"或"或"字在"// "符号之前使用.例如:"/ sitecore/content/Home/#news and events#// ".
更新:我已经确认这也适用于快速查询.
End of string expected at position 27.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Sitecore.Data.Query.ParseException: End of string expected at position 27.
Source Error:
Line 21: protected void Page_Load(object sender, EventArgs e)
Line 22: {
Line 23: Sitecore.Context.Database.SelectSingleItem("fast:/sitecore/Content/Home/Test-Item");
Line 24:
Line 25: Model = Sitecore.Context.Item;
Run Code Online (Sandbox Code Playgroud)
#escapes#运行相同的代码:
Sitecore.Context.Database.SelectSingleItem("fast:/sitecore/Content/Home/#Test-Item#");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7431 次 |
| 最近记录: |