Predicate.ToString.. is it there??

Posts   
 
    
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 28-Nov-2005 19:15:40   

Part of my auditing logic is to log whatever filter (Predicate expression) was used to fetch the object/collection. I started to build a generic function that can return a friendly string representation of the Predicate object but thought myabe LLBL already has this facility...??

Is there an easy way to do this?.. if NOT how do you think I should proceed to build such a function ??

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 29-Nov-2005 07:06:50   

Please try

PredicateExpression.ToQueryText()

Retrieves a ready to use text representation of the contained Predicate.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 29-Nov-2005 11:05:40   

Be sure to set the DbSpecificCreatorToUse property to an instance of the DQE 's DbSpecificCreator class.

Frans Bouma | Lead developer LLBLGen Pro
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 29-Nov-2005 11:37:56   

Otis wrote:

Be sure to set the DbSpecificCreatorToUse property to an instance of the DQE 's DbSpecificCreator class.

forgive my ignorance but I have no idea what you meen flushed

What are these two parameters required by the ToQueryText method

Function ToQueryText( _
   ByRef uniqueMarker As Integer, _
   ByVal inHavingClause As Boolean _
) As String

What I want to do is a simple (and generic to work with any DAL/DQE) PredicateExpressionToString function that retreives a string representation of the PredicateExpression object

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 29-Nov-2005 12:53:34   

ToQueryText() produces SQL, for the WHERE clause (for example). Prior to call ToQueryText, you should set the dbspecific creator object of the predicateexpression. See the following example for sqlserver:


myPredicateExpression.DatabaseSpecificCreator = new SD.LLBLGen.Pro.DQE.SqlServer.SqlServerSpecificCreator();
int uniqueMarker = 0;
string s = myPredicateExpression.ToQueryText(ref uniqueMarker, false);

That's about it.

Frans Bouma | Lead developer LLBLGen Pro
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 03-Dec-2005 09:47:18   

Otis wrote:

ToQueryText() produces SQL, for the WHERE clause (for example). Prior to call ToQueryText, you should set the dbspecific creator object of the predicateexpression. See the following example for sqlserver:


myPredicateExpression.DatabaseSpecificCreator = new SD.LLBLGen.Pro.DQE.SqlServer.SqlServerSpecificCreator();
int uniqueMarker = 0;
string s = myPredicateExpression.ToQueryText(ref uniqueMarker, false);

That's about it.

If I want to create this function in my DALDBSepecific assembly, can I use an include template to generate such code (so that I don't modify the original templates)? If yes, can you please tell me how to do that??

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 04-Dec-2005 12:17:28   

omar wrote:

Otis wrote:

ToQueryText() produces SQL, for the WHERE clause (for example). Prior to call ToQueryText, you should set the dbspecific creator object of the predicateexpression. See the following example for sqlserver:


myPredicateExpression.DatabaseSpecificCreator = new SD.LLBLGen.Pro.DQE.SqlServer.SqlServerSpecificCreator();
int uniqueMarker = 0;
string s = myPredicateExpression.ToQueryText(ref uniqueMarker, false);

That's about it.

If I want to create this function in my DALDBSepecific assembly, can I use an include template to generate such code (so that I don't modify the original templates)? If yes, can you please tell me how to do that??

See 'adding your own code to the generated code' in the documentation for how to use an include template. You should add an include template to the DataAccessAdapter class and simply generate a method which accepts a predicate and returns a string.

Frans Bouma | Lead developer LLBLGen Pro