Elad Lachmi
Elad Lachmi

Reputation: 10561

Extension for Umbraco /base

I am writing a RestExtension for /base. I have the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using umbraco.presentation.umbracobase;
using umbraco.NodeFactory;

namespace ElkeslasiBase
{
    [RestExtension("Collections")]
    public class Collection
    {
        [RestExtensionMethod()]
        public static string GetCollection(string collectionID)
        {
            var currentNode = Node.GetCurrent();
            var SelectedCollection = currentNode.ChildrenAsList.Where(elm => elm.Name == collectionID);
            return collectionID;
        }
    }
}

The problem is that the compiler throws out an error for the lambda expression.

Delegate 'System.Func<umbraco.interfaces.INode,int,bool>' does not take 1 argument

From digging around in Google, I found several people doing exactly this. Maybe I'm missing a reference? Or maybe something else?

Upvotes: 3

Views: 1047

Answers (1)

Elad Lachmi
Elad Lachmi

Reputation: 10561

I finally found an updated example somewhere. The linq code should look like this:

Node SelectedCollection = currentNode.Children.OfType<Node>().Where(elm => elm.Name == collectionID).SingleOrDefault();

That's three hours of my life I'll never get back...

Upvotes: 2

Related Questions