Instantly share code, notes, and snippets.

What would you like to do?
Use PredicateBuilder to search for partial matches for keywords in an entity property based on this answer -
//Choose "C# Statement(s)" in the Type drop-down.
//Write the code that LINQPad should execute.
//Put a closing curly-bracket ("}") at the end.
//Write as many classes and methods as you like.
//On the last class/method, omit closing curly-bracket.
//To remove PredicateBuilder errors, see
var Names = new List<Name> {
new Name {
Company = "Test Soft"
new Name {
Company = "Dance Like a Monkey"
new Name {
Company = "Test widgets"
new Name {
Company = "Monkey Soft"
var predicate = PredicateBuilder.False<Name>();
List<string> names = new List<string>();
foreach(string name in names)
predicate = predicate.Or(n => n.Company.Contains(name));
var results = (from n in Names
select(new{ n.Company}));
public class Name
public string Company { get; set; }
//} //This is deliberately left off so that it will work as a Linqpad statement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment