日期:2014-05-18 浏览次数:20796 次
void Main() { var source=new List<Tim> { new Tim{ ID="12",Name="t", School=""}, new Tim{ ID="123",Name="t", School=""}, new Tim{ ID="1234",Name="t", School=""}, new Tim{ ID="1",Name="t123", School=""}, new Tim{ ID="2",Name="t", School="0123"} }; var query=from x in source let temp=source.Select(t=>new{ID=t.ID,all=t.ID+","+t.Name+","+t.School}).Where(t=>t.all.Contains("123")).Select(t=>t.ID) where temp.Contains(x.ID) select x; } class Tim { public string ID{get;set;} public string Name{get;set;} public string School{get;set;} } //此处要求ID唯一