2019独角兽企业重金招聘Python工程师标准>>>
int[] grades = { 1, 2, 3, 4, 5, 6, 7, 8 };// 59, 82, 70, 56, 92, 98, 85 };
int rd = grades.Length;
var iqg = grades.AsQueryable().OrderBy((q)=>q);
for(int i =0;i lowerGrades =
grades.AsQueryable().OrderByDescending(g => g).Skip(3);
Console.WriteLine("All grades except the top three are:");
foreach (int grade in lowerGrades)
Console.WriteLine(grade);
以上两种代码都很正常,但我操作数据库的时候却不正常(我的目的就是想将记录都删除掉):
var im3ts = dbcontext.im3table.Where((im3t) => im3t.MAC == tmpmac);
int im3trd = im3ts.Count();
for (int i = 0; i < im3trd; i++)
{
im3table im3t = im3ts.OrderBy((it) => it.id).Skip(i).First();
del(dbcontext, im3t);
Console.WriteLine("deleted im3table id=" + im3t.id);
}
发现:删除时总是间隔一行删除一条记录,比如说有记录 id=1,2,3,4,5,6,7,8,9,那么删除的时候会将1,3,5,7,9删除,而2,4,6,8没有删除,并且最后还会出现异常