Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • teus 42 posts 74 karma points
    Oct 19, 2010 @ 13:25
    teus
    0

    Linq to Umbraco AncestorOrDefault bug ?

    Hello,

    I was wondering if I found a bug or are just using it wrong.

    If I use

     from obj in ctx.SomeChild
     select obj.AncestorOrDefault<AnotherType>()

    I get the error below (The given key was not present in the dictionary) when SomeChild doesn't have a parent of type AnotherType.Is this error avoidable?

    Thanks

    Teus

     

     

     

     

    The given key was not present in the dictionary.

    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: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace:

    [KeyNotFoundException: The given key was not present in the dictionary.]
       System.Collections.Generic.Dictionary`2.get_Item(TKey key) +12681071
       umbraco.Linq.Core.Node.<DynamicNodeCreation>d__6.MoveNext() +594
       System.Linq.WhereEnumerableIterator`1.MoveNext() +196
       System.Linq.<CastIterator>d__b1`1.MoveNext() +296
       System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +200
       umbraco.Linq.Core.DocTypeBase.AncestorOrDefault(Func`2 func) +706
       umbraco.Linq.Core.DocTypeBase.AncestorOrDefault() +315
       BO.Umb.TA.UserControls.MijnGegevens.<LoadMySearchResults>b__2(Acteur obj) +60
       System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +6294506
       System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +472
       System.Linq.Enumerable.ToList(IEnumerable`1 source) +80
       BO.Umb.TA.UserControls.MijnGegevens.LoadMySearchResults() +615
       BO.Umb.TA.UserControls.MijnGegevens.Page_Load(Object sender, EventArgs e) +152
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
       System.Web.UI.Control.LoadRecursive() +71
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3048
    



    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 20, 2010 @ 00:03
    Aaron Powell
    0

    Which Umbraco version?

  • teus 42 posts 74 karma points
    Oct 20, 2010 @ 09:07
    teus
    0

    umbraco v 4.5.2 (Assembly version: 1.0.3891.20719)

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 20, 2010 @ 11:13
    Aaron Powell
    0

    See if there's a bug on codeplex already and if not can you lodge one.

    I haven't used it since I wrote that though.

  • teus 42 posts 74 karma points
    Oct 20, 2010 @ 11:27
    teus
    0

    logged as item 29217

    http://umbraco.codeplex.com/workitem/29217

    regards

    Teus

  • Kurniawan Kurniawan 202 posts 225 karma points
    Feb 02, 2011 @ 02:28
    Kurniawan Kurniawan
    0

    Hi There,

     

    Is there any solution for this ?


    I try to get all child nodes of particular type which give me the same error.

    The given key was not present in the dictionary


    For example get all news item in news category

    newsCat.NewsItems.ToList();

     

    How do you get the child node of particular type in umbraco ?

     

    Thanks

     

     

     

     

     

  • Anthony Thomas 4 posts 24 karma points
    Oct 28, 2013 @ 19:53
    Anthony Thomas
    0

    Did you find any resolution for this issue?

Please Sign in or register to post replies

Write your reply to:

Draft