Combining multiple fuilds in a predicate filter

Posts   
 
    
Posts: 9
Joined: 16-Jul-2008
# Posted on: 16-Jul-2008 19:28:51   

I want to do a search on my Members table. It's possible a person might search for "last name, first name" , so I need in a filter "where lastname & ", " & firstname = " & keyword

I need to check against two combined fields with a string against my keyword.

any ideas?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 17-Jul-2008 05:50:35   

Hi there,

If you are using SQLServer and LLBLGen v2.5+ you could do that this way (assuming Adapter TemplateSet and C#):

// collection to fetch
EntityCollection<CustomersEntity> customers = new EntityCollection<CustomersEntity>(new CustomersEntityFactory());

// filter
IRelationPredicateBucket filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(CustomersFields.FirstName.SetExpression(CustomersFields.LatName + ", " + CustomersFields.FirstName) == "Ana Trujillo, Owner");

// fetch results
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
    adapter.FetchEntityCollection(customers, filter);
}

If that doesn't work for you, please post some relevant informationwink

David Elizondo | LLBLGen Support Team