Using SQL directly instead of predicates...

Posts   
 
    
Posts: 497
Joined: 08-Apr-2004
# Posted on: 01-Jun-2007 12:28:08   

Hi,

Some developers at "my place" are SQL guru's, but know nothing or little about LLBLGen. They are asking me if it possible that they can specify a "where" clause as pure SQL, without using the predicate system.

I'm not saying this is something you should do, but is it possible?

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 01-Jun-2007 15:42:17   

Have they checked the Native language filter construction feature? (The ability to formulate filters using compact, native language constructs)

Instead of:

PredicateExpression.Add(new FieldCompareValuePredicate(OrderFields.EmployeeID, null, ComparisonOperator.Equal, 2));

You can do this:

PredicateExpression.Add(OrderFields.EmployeeID == 2);

This can be quite handy in many situations.

Also if something gets too complicated, they can fall back to stored procedures and or database views, and call/map then from LLBLGen Pro.

Posts: 254
Joined: 16-Nov-2006
# Posted on: 02-Jun-2007 23:19:48   

It would be great if someone could write a utility to parse ANSI SQL and generate corresponding generic LLBLGen code.

This would help those coming from a SQL back ground to quickly understand the corresponding object model LLBLGen provides to search the data to get the same results.

Any volunteers?

jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 03-Jun-2007 01:49:39   

I can sympathize with your situation. I too came from a stored proc/sql scripting background and it took a while to adjust to predicates. however once it clicks (should only take a day or two of constant use) it's a great system. and with the provided overloads/shortcuts it almost feels like writing sql scripts.

here are some tips/hints that may help: * think of PredicateExpressions as a set of parentheses. * You can use & and | as and/or shortcuts with predicates which may help make sense when switching from scripting to OOP. * if you (or your team members) have any questions post of the forum and the any one of the great talents here on the forums will assist you.

JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 04-Jun-2007 23:42:25   

This question has been asked before..

http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=6734&HighLight=1

Create a derived class from Predicate and emit your SQL in an override of ToQueryText.