Groups > Asp .Net > Data Access and ObjectDataSource Control > Re: Is there something wrong with this Linq query?




Is there something wrong with this Linq query?

Is there something wrong with this Linq query?
Wed, 2 Apr 2008 04:48:36 +0000
I cant figure out whats wrong with this but it isn't returning anything.. 

public IEnumerable getTree()
        {
            foreach (PageController root in Values.Where(p => p.parent ==
null).OrderBy(p => p.position))
            {
                yield return root;
                foreach(PageController leaf in getTree(root))
                yield return leaf;
            }

        }

        public IEnumerable getTree(PageController page)
        {
            foreach (PageController node in Values.Where(p => p.parent ==
page.id).OrderBy(p => p.position))
            {
                if (node.pageLvl)//parent
                {
                    yield return node;
                    foreach (PageController leaf in getTree(node))
                    yield return leaf;
                }
                else
                {
                    yield return node;
                }
            }
        }
Post Reply
Re: Is there something wrong with this Linq query?
Thu, 3 Apr 2008 08:15:34 +0000
Hi ChanceUSC,

I can't understand clearly from your codes provided.  

But for these kind of problems, debuging your application is always the best way
to locate the error. You can set break points and track the codes, then you'll
see how the application run and find the error easily. Please take a try and if
you still can't find the error, please feel free to let me know.

 

Thanks.
Post Reply
about | contact