Skip to content

Add support for lambda expressions #27

@terrajobst

Description

@terrajobst

Ported from CodePlex

It would be great if we would have support for lambda expressions. Lambda expressions would allow clients to write functions which accepts expressions written in SQL. For example imagine you would have a function in C# like this:

delegate bool TaskPredicate(Task task);
Task FindParentTask(Task startingTask, TaskPredicate taskPredicate)
{
 Task currentTask = startingTask;
 while (currentTask != null)
 {
  if (taskPredicate(currentTask))
  return currentTask;

  currentTask = currentTask.Parent;
 }

 return null;
}

This function should be accessible in the query engine like this:

SELECT  t.Handle,
        t.Name,
        FindParentTask(t, (Task parentTask) -> parentTask.OutlineLevel >= 1 AND parentTask.EnterpriseOutlineCode8.FullName = 'a.b.c').Handle
FROM    tasks t

The lambda expression syntax is something like this:

(<ParameterType> <ParameterName ... ) -> <Expression>

In contrast to C# 3.0 I would suggest making the declaring parameters explicit is better. First it radically simplifies the overload resolution process and secondly if improves the readabillity of the lambda expression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions