Copied to clipboard

Flag this post as spam?

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


  • Jeff Grine 149 posts 189 karma points
    Dec 03, 2010 @ 20:12
    Jeff Grine
    0

    LINQ AncestorOrDefault

    I'm getting the same key not found error as this post when using AncestorOrDefault. In my case the doc type I'm looking for definitely exists. Works fine in my development environment, but not on test or production servers. My work around for now is to manually crawl up the tree by grabbing the id of each parent one at a time. So instead of 

     

     

    var events = (from ev in ctx.Events
    where ev.AncestorOrDefault<SiteRoot>().Id==siteId...
    

    I'm doing

    int parentId = ctx.EventsFolder.Where(p => p.Parent<SiteRoot>().Id == siteID).First().Id
    var events = (from ev in ctx.Events
    where ev.Parent<EventsFolder>().Id==parentId...

    Thought it might have something to do with generating the context from my development environment, but when I replace with code generated from the production environment, it still throws the error. And still works in dev.

    This is 4.5.2 for .net 3.5 running on IIS 5?(dev - XP), 6? (test - Server 2003), 7.5 (prod - server 2008). All the dlls were copied from the same source. Any ideas?

    Thanks
    Jeff

     

     

Please Sign in or register to post replies

Write your reply to:

Draft