标签:style blog ar color sp on div art log
工作随笔
1 // LinQ 分页 2 listsearch = listsearch.Take(pageSize * pageIndex).Skip(pageSize * (pageIndex - 1)).ToList();
1 //LinQ 按列去重 2 listDistinct = list.Distinct(new ExampleComparer()).ToList(); 3 4 //去重类 (按FileName 去重) 5 class ExampleComparer : IEqualityComparer<DistributeDownFileInfo> 6 { 7 public bool Equals(DistributeDownFileInfo x, DistributeDownFileInfo y) 8 { 9 if (Object.ReferenceEquals(x, y)) 10 return true; 11 if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null)) return false; 12 return x.FileName == y.FileName; 13 } 14 public int GetHashCode(DistributeDownFileInfo example) 15 { 16 if (Object.ReferenceEquals(example, null)) return 0; 17 return example.FileName.GetHashCode(); 18 } 19 }
1 //FindAll 匹配条件的所有元素 2 listDownTime = listDownTime.FindAll(b => b.FileName =="FileName").ToList(); 3 //判断是否存在“FileName” 4 bool reuslt = listDownTime.FindAll(b => b.FileName == "FileName").Count < 1
1 //查询 like fileName 2 listAll = (from c in listAll where c.FileName.Contains(fileName) select c).ToList();
1 //查询 等于 2 listAll = (from c in listAll where c.ClassID == Convert.ToInt32(classidList) select c).ToList();
1 //查询 or 2 string[] strArray = cascadeIPs.Split(‘,‘); 3 listAll = (from p in listAll where (strArray).Contains(p.CascadeIP) select p).ToList();
1 //查询 Between and 2 listAll = (from u in listAll 3 where 4 u.DownTime > Convert.ToDateTime(startTime) && u.DownTime < Convert.ToDateTime(endTime) 5 || u.DownErrTime > Convert.ToDateTime(startTime) && u.DownErrTime < Convert.ToDateTime(endTime) 6 || u.RunTime > Convert.ToDateTime(startTime) && u.RunTime < Convert.ToDateTime(endTime) 7 || u.RunErrTime > Convert.ToDateTime(startTime) && u.RunErrTime < Convert.ToDateTime(endTime) 8 select u).ToList();
标签:style blog ar color sp on div art log
原文地址:http://www.cnblogs.com/moshikatuo/p/4123192.html