NOODB: Complex Where Building

The where parser is complete for AND and OR. I have several samples; this is the most complex so far. The only operator is =. Adding < and > is a no brainer. LIKE will take a bit more work; IN will probably take quite a bit more work. But, it’s getting there.

Remember that this is a two-step process. The first step converts the NOODB query to a object graph that’s more easily convertible to any other format. In this case, the other format is sql. I haven’t touched the Sql convert in a long time; all the work has been in step 1. This proves that step 2 is very simple. I added complexity without having to update the Sql converter.

NOODB Query

from p in QueryPerson 
                where 
                    ((p.FirstName='Jay' && p.LastName='Allard')
                    || (p.FirstName='Amy' && p.LastName='Harrington')
                    || p.Random = 'blah') && ((p.a = 1 || p.b = 2 || p.c = 3) || p.d = 4 && p.e = 5))

SQL Where Clause

(
	
	(
		
		(
			[p].[FirstName] = 'Jay' 
			And [p].[LastName] = 'Allard'
		)		
		Or 
		(
			[p].[FirstName] = 'Amy' 
			And [p].[LastName] = 'Harrington'
		)		
		Or [p].[Random] = 'blah'
	)	
	And 
	(
		
		(
			[p].[a] = 1 
			Or [p].[b] = 2 
			Or [p].[c] = 3
		)		
		Or [p].[d] = 4 
		And [p].[e] = 5
	)	
)
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: