Sitecore Fast Query Gives Parse Exception

后端 未结 2 677
无人共我
无人共我 2021-01-17 09:35

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.

相关标签:
2条回答
  • 2021-01-17 10:03

    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.

    0 讨论(0)
  • 2021-01-17 10:06

    When using Sitecore Query, you need to escape item names with dashes. From SDN:

    Items with dashes in names (“-”) should be included in “#” symbols. Please use such syntax: /sitecore/content/Home/#About-us#. Otherwise you may get the following error: Invalid lookup source "/sitecore/content/TestSiteB/Home/About-us": End of string expected at position 38. Also, an item name should be included in “#” symbols if it contains “and” or “or” word and is used before “//” symbols. For example: "/sitecore/content/Home/#news and events#//".

    UPDATE: I have confirmed that this applies to Fast Query as well.

    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;
    

    The same code runs fine with #escapes#:

    Sitecore.Context.Database.SelectSingleItem("fast:/sitecore/Content/Home/#Test-Item#");
    
    0 讨论(0)
提交回复
热议问题