How to find out in code what SQL is generated?

Posts   
 
    
slade52
User
Posts: 46
Joined: 15-Aug-2007
# Posted on: 10-Jun-2010 05:46:17   

Hello there,

I'm using LLBLGen Pro v2.6 Final Oct 6th 2008 with .NET 3.5 on SQL Server 2005. Self-Servicing architecture.

I'm having some intermittent NullReferenceExceptions when calling TypedListDAO GetMultiAsDataTable() calls. The arguments can change over time as they are built up in code from user input. I'm sure that the exceptions are caused by badly formed contents of the PredicateExpressions, SortExpressions, ResultsetFields parameters, as I have seen that cause NullRef exceptions before.

I'm trying to find a way to see what's going on so I can log it in my exception handler. There are two things I'd appreciate some help with please.

  1. Is there a way to see what SQL query is generated by the GetMultiAsDataTable call ?

  2. Is there a way to enumerate PredicateExpressions, ResultsetFields, SortExpressions, RelationCollections, and GroupByCollections to examine their contents ?

The problem is intermittent so I'd prefer to collect this information using C# code in a catch block rather than have tracing running full time.

Thanks in advance for any help. Mike

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 10-Jun-2010 06:49:49   

slade52 wrote:

  1. Is there a way to see what SQL query is generated by the GetMultiAsDataTable call ?

Yes wink Please read Troubleshooting and debugging. However, due to the exception I think theres wont be any generated sql, as the error is happening (I think) before the query is built. To know more about that, we will need more info (exception message and stack trace, and llblgen runtime library version).

slade52 wrote:

  1. Is there a way to enumerate PredicateExpressions, ResultsetFields, SortExpressions, RelationCollections, and GroupByCollections to examine their contents ?

Yes you can. Please read LLBLGen Reference manual and/or the VSNet Object Browser to know more about the LLBLGgen classes hierarchy. I however would recommend to you to inspect the content of the user input before putting it in LLBLGen classes (SortClauses, PredicateExpression, etc..).

David Elizondo | LLBLGen Support Team