Dynamic LINQ for LLBLGen?

Posts   
 
    
Meteor
User
Posts: 67
Joined: 06-Apr-2007
# Posted on: 19-Nov-2009 02:09:09   

As I'm sure you're aware, Microsoft recently brought out a set of Dynamic Linq extensions, so that a query like


var query = 
from p in Northwind.Products
where p.Category == 2 and p.UnitPrice > 3
orderby p.SupplierId
select p;

could be rewritten as


var query = 
Northwind.Products
.Where("CategoryId==2 and UnitPrice>3")
.OrderBy("SupplierId");

The obvious benefit being that it's very easy to build up a query using strings and case statements.

Are there any plans to provide this functionality for LLBLGen?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Nov-2009 06:03:22   

Meteor wrote:

The obvious benefit being that it's very easy to build up a query using strings and case statements.

Could you provide and example of such benefit? Sorry but I really don't see it.

Meteor wrote:

Are there any plans to provide this functionality for LLBLGen?

I tested the library. Some queries works, some projections no. IMHO it's not that flexible and I don't know if the library will create the appropriate expression trees.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 19-Nov-2009 10:09:26   

If you want to create queries from strings, IMHO it's best to use our native query api, which is very flexible and designed with dynamic queries in mind.

If you really want to use linq for this, you can also use the predicatebuilder class: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=14224 which is made for dynamic queries.

Frans Bouma | Lead developer LLBLGen Pro
Meteor
User
Posts: 67
Joined: 06-Apr-2007
# Posted on: 19-Nov-2009 21:50:28   

Thanks Frans.

I discovered the predicatebuilder class after I posted, and have used it successfully to do the job on hand.