Dynamic quries

Posts   
 
    
imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 06-Apr-2010 21:56:50   

I am using Self servicing model and have to write llbl code for a query like this


SELECT StartDate, MIN(Field1) AS FieldName1, MAX(Field2) FieldName2
FROM MyTable1 
WHERE Field1 IS NOT NULL OR Field2 IS NOT NULL
GROUP BY StartDate
ORDER BY StartDate

The problem is that 1) The Field names like **Field1 **or **Field2 **can change 2) there ia also filter where the same fields are using. 3) The number of these fields in the query can change also. For instance in above example I have **Field1 **and **Field2 **but in some case I may have Field1, Field2, Field3, Field4

Any ideas on what is the best of implementing this type of scenario?

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 06-Apr-2010 22:12:46   

Dynamic queries such as these are easy to build using the LLBLGen predicate system.

Have a read through and feel free to come back to us with any more specific questions. It is quite often a good idea to have a go at something, and then post what you have tried to at least give us a starting point to help you from.

The same answer also applies to your other question BTW simple_smile

Matt

imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 06-Apr-2010 22:41:58   

OK, I will go over it and come back if there are any questions. Thanks for your prompt response though