EntityCollection filter

Posts   
 
    
TomV
User
Posts: 76
Joined: 31-Jan-2008
# Posted on: 29-Feb-2008 16:33:22   

Hi,

The last hour I've been searching the forum for the answer to my problem. I have an EntityCollection, fetched from the database, and I want to check if a certain value is available in the collection.

I used collection.FindMatches which return me a nice List<int>. So far so good.

The problem is that I want to check for corresponding lower case value. I'm not able to find a solution. I've been looking around and used EntityView2, etc...

Small example: Collection contains enties with a key field, values "Tom, Peter, Paul, ...". The values I want to search for are: tom, peter, paul. I don't find any matches... cry

Anybody some idea so the FindMatches for tom returns the Tom entity?

Kind regards, TomV

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Feb-2008 18:00:32   

Maybe you are filtering this way...

// this test will fails
IPredicateExpression filter = new PredicateExpression();
filter.Add(CustomerFields.FisrtName == "tom");
List<int> matches = myCollection.FindMatches(filter);
Assert.IsTrue(matches.Count > 0, "...");

You should use _FieldLikePredicate _with CaseSensitiveCollation.

// this test will works ok
IPredicateExpression filter = new PredicateExpression();
FieldLikePredicate sensitiveFilter = new FieldLikePredicate(CustomerFields.FisrtName, null, "tom".ToUpper());
sensitiveFilter.CaseSensitiveCollation = true;
List<int> matches = coincidencias.FindMatches(filter);
Assert.IsTrue(matches.Count > 0, "...");

Let me know if you made it wink

David Elizondo | LLBLGen Support Team
TomV
User
Posts: 76
Joined: 31-Jan-2008
# Posted on: 01-Mar-2008 13:52:13   

Thanks daelmo,

When I used the following code, it worked.

FieldLikePredicate sensitiveFilter = new FieldLikePredicate(CustomerFields.FisrtName, null, "tom".ToUpper()); sensitiveFilter.CaseSensitiveCollation = true; List<int> matches = coincidencias.FindMatches(sensitiveFilter);

Thanks a lot for your help!

Kind regards TomV