Query By Example (QBE)

Posts   
 
    
mhnyborg
User
Posts: 14
Joined: 26-Apr-2006
# Posted on: 17-Jul-2008 00:02:01   

I have a search form with some fields from the view I use to search in. In NH I would use QBE is there something like that in LLBLGen.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 17-Jul-2008 06:14:31   

Here you can use IPredicateExpression and IRelationPredicateBucket and add in those almost anything. You also can use natural language to add criteria:

IRelationPredicateBucket filter = new RelationPredicateBucket();
// this is a LIKE predicate
filter.Add(CustomerFields.CompanyName % "%some company.."%);

So, if you have a search form, you could something like:

if (!string.IsNullOrEmpty(txtFirstName.Text))
{
     filter.Add(CustomerFields.FisrtName == txtFirstName.Text);
}

if (!string.IsNullOrEmpty(txtLastName.Text))
{
     filter.Add(CustomerFields.LastName == txtLastName.Text);
}

...

// then use that IRelationPredicateBucket at your fetch routing

If you are using LLBLGenProDataSource(2) to bind the results to some control (say a grid), you can filter on-the-fly without write any code.

David Elizondo | LLBLGen Support Team