https://www.cnblogs.com/dullfish/p/6101912.html
List<string> existCode = new List<string> { "27101210", "27101220", "27101230", "27101911", "27101921", "27101922", "27101929", "27101991", "27101992", "27101993", "27101999" }; List<string> getCode = new List<string> { "27101210", "27101220" }; var exp1 = existCode.Where(n => getCode.Exists(t => n.Contains(t))).ToList();//查询的list存在固定组里的值 俩个list比较
linq基础查询 var query = from r in p where r.Age == "20" orderby r.Age descending select r;
foreach (Person st in query)
{
Console.WriteLine("***************");
Console.WriteLine("姓名:" + st.Name);
Console.WriteLine("班级:" + st.Sex);
Console.WriteLine("年龄:" + st.Age);
}
- 联合查询-join
//查询出集合qSt中year等于集合qSc中year的元素并形成新的集合
var qjoin = from r in qSt
join c in qSc
on r.year equals c.year
select new
{
Year = r.year,
stName = r.name,
scName = c.name
};