Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for lambda expressions #27

Open
terrajobst opened this issue Oct 31, 2014 · 0 comments
Open

Add support for lambda expressions #27

terrajobst opened this issue Oct 31, 2014 · 0 comments

Comments

@terrajobst
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant