arschr wrote:
In Adapter you can call ToString() and you get the query (call ToString() of hte passed in IRetrievalQuery or IActionQuery object).
I was thinking of sooner, getting it out of the the predicate expressions and buckets as an aid in debugging and maybe somehow using it to describe to a user the logic of what they may be dynamically building.
Ok, well, that's possible. You have to create a subclass of the DataAccessAdapter class and add a method which calls the base class' Insertpersistenceinfo(relations) and Insertpersistenceinfo(predicateexpression) methods.
Then, create in that method a DatabaseSpecificCreator object, for example for SqlServer that's the SqlServerSpecificCreator. This object is required for creating parameters.
Then do:
myBucket.Relations.DatabaseSpecificCreator = myDatabaseSpecificCreator;
myBucket.PredicateExpression.DatabaseSpecificCreator = myDatabaseSpecificCreator;
THen, you can call myBucket.Relations.ToQueryText(ref uniqueMarker) and myBucket.PredicateExpression.ToQueryText(ref uniqueMarker)
uniqueMarker is an int parameter which is used to create unique parameters.
The two ToQueryText() methods produce the sql you're looking for. It seems more than it looks, it's about 5 lines of code. You can wrap this in 1 method which accepts a RelationPredicateBucket and does the work for you, place that method in the DataAccessAdapter derived class.
SelfServicing is a little easier, you just have to create a databasespecificcreator and call the toQueryText methods.