I have a string with semi-comma separated names:
string names = "Jane;Harry";
I also have a list of customer objects:
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
List<Customer> customers = new List<Customer>();
customers.Add(new Customer(){FirstName="John", LastName="Doe"});
customers.Add(new Customer(){FirstName="Jane", LastName="Doe"});
customers.Add(new Customer(){FirstName="Harry", LastName="Potter"});
var query = from c in customers
select c;
How do I create a query that returns only those customers that has a first name that is in the semi-comma separated list?
Something like the T-SQL SELECT FistName FROM customer WHERE FirstName IN (list)
(sort of)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…