Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic LINQ and Dynamic Lambda expressions?

What is the best way of dynamically writing LINQ queries and Lambda expressions?

I am thinking of applications where the end user can design business logic rules, which then must be executed.

I am sorry if this is a newbie question, but it would be great to get best practices out of experience.

like image 494
Sklivvz Avatar asked Sep 22 '08 09:09

Sklivvz


People also ask

What is difference between LINQ and lambda expression?

Language Integrated Query (LINQ) is feature of Visual Studio that gives you the capabilities yo query on the language syntax of C#, so you will get SQL kind of queries. And Lambda expression is an anonymous function and is more of a like delegate type.

Can we use dynamic in lambda expression?

In 2010, the Dynamic Type was introduced and that gave us the ability to create dynamic lambda expressions.

What is Dynamic LINQ?

The Dynamic LINQ library exposes a set of extension methods on IQueryable corresponding to the standard LINQ methods at Queryable, and which accept strings in a special syntax instead of expression trees.

What is LINQ and lambda expressions?

The term 'Lambda expression' has derived its name from 'lambda' calculus which in turn is a mathematical notation applied for defining functions. Lambda expressions as a LINQ equation's executable part translate logic in a way at run time so it can pass on to the data source conveniently.


1 Answers

I cannot recommend higher than you reading through the postings of Bart De Smet (http://community.bartdesmet.net/blogs/bart/), he is really brilliant when it comes to Lambda.

His recent series covered dynamic Lambda, starting with http://community.bartdesmet.net/blogs/bart/archive/2008/08/26/to-bind-or-not-to-bind-dynamic-expression-trees-part-0.aspx

Absolutely beautiful code.

like image 158
Aaron Powell Avatar answered Sep 28 '22 00:09

Aaron Powell