score:1

Accepted answer

i think what you are looking for is:

var zippredicate = predicatebuilder.false<nameaddress>();
    list<string> zips = new list<string>();
    zips.add("90210");
    zips.add("90211");
    foreach (var item in zips)
    {
        zippredicate = zippredicate.or(n=> n.zip.contains(item) && n.purpose=="street address");        
    }        
    var zipresult = from s in nameaddresses 
    .asexpandable()
    .where(zippredicate)
    select new{s.id, s.zip, s.purpose};

zipresult.dump();

edit

one more thing as well, if you want to drop building up the predicate, you should be able to do something like: .where(n=>zips.contains(n.zip) && n.purpose=="street address") the important piece is that your entity property component comes inside the .contains(). this would shorten your code to:

    list<string> zips = new list<string>();
    zips.add("90210");
    zips.add("90211");

    var zipresult = from s in nameaddresses 
    .asexpandable()
    .where(n=>zips.contains(n.zip) && n.purpose=="street address")
    select new{s.id, s.zip, s.purpose};

zipresult.dump();

which i like better for readability. i would expect the query that ends up getting executed is the same either way.


Related Query

More Query from same tag