Usinq Linq to select items that is in a semi-comma separated string?

后端 未结 3 1400
孤城傲影
孤城傲影 2020-12-18 08:23

I have a string with semi-comma separated names:

string names = \"Jane;Harry\";

I also have a list of customer objects:

pub         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-18 08:55

    You can try this.

    List firstnames = names.Split(';').ToList();

    var query = from c in customers
                where firstnames.Contains(c.FirstName) 
                select c ;    
    

提交回复
热议问题