How to match part of a string?

How to match part of a string?

Old forum URL:

mtrtm posted on Monday, October 22, 2012

Hi all,

This seems like a very simple question, but searching for 'like' isn't very helpful and searching wildcards for csla isn't coming up with any usable results.

Basically, I would like to get business objects back that partially match a search term. For instance, if a user enters 'matt' I want results to include 'matt' and 'matthew'.  Is there an easy way to do this via criteria or any other easy trick to denote a 'like' or 'wildcard' match on a string field that I am overlooking? 

Curelom replied on Monday, October 22, 2012


mtrtm replied on Monday, October 22, 2012

Hi Curelom - sorry, I should have been a bit more explicit.  Here is my code:



PeopleCriteria fetchCriteria = new PeopleCriteria();

fetchCriteria.Name = nameToSearchFor;


DataPortal<People> dp = new DataPortal<People>();

dp.FetchCompleted += UpdateSearchResults_FetchCompleted;




You will notice the second line I am setting the name to whatever I want to search for. But using the criteria like that translates into equality. Is there any way in the criteria to specify that, instead of doing an equals, I want to do a like for that particular field?  We need the ability to do either/or, so it's not like I can just switch to always doing a .Contains in the fetch method.  

Curelom replied on Monday, October 22, 2012

Could you show your DataPortal Fetch method?

JonnyBee replied on Monday, October 22, 2012


Add more properties to your criteria object to instruct which type of search to perform i DataPortal_Fetch

mtrtm replied on Wednesday, October 24, 2012

Hi Jonny,

Thanks again for the answer - very simple and straightforward. I just added the property and the following line, and now in my fetch I can differentiate between equals and like.

fetchCriteria.MatchPartialName = true;

Copyright (c) Marimer LLC