嘿所有, 我想根据DateTime值(特别是年份)从当前记录中的一个记录中选择一个值正在输入和已经在那里(除非第一行)。我的id因为删除而跳过(我认为修复它的方法也适用)。 有人想帮我查询吗? (注意:我之前已经重新订购了ID,但是我忘记了当我这样做时使用了哪种语言,我似乎无法找到它的参考,这样做通常看起来像是浪费资源) 。 谢谢, Ruben
Hey all, I would like to select a value from a record that is one previous from the current record based on the DateTime value (specifically: year) that is being input and one that is already in there (unless first row). My id's skip because of deletes (I suppose a fix-it method for that would work too). Anyone want to help me with the query? (Note: I have re-ordered ID's before, but I forget which language that was in when I did it, I can't seem to find a reference on that, and doing that often seems like it would be a waste of resources). Thanks, Ruben
推荐答案我希望这可以帮到你 I hope this help you //list object var lstValue = new List<int>(); //insert 0 -> 19 for (var i = 0; i < 20; i++) lstValue.Add(i); //set up currentValue var crValue = 3; //sort list by lstValue = lstValue.OrderByDescending(s => s).ToList(); //get index of current value var index = lstValue.IndexOf(crValue); Console.WriteLine(index); //get value previous if (index > 0) { var prvValue = lstValue.Skip(index - 1).First(); Console.WriteLine(prvValue); }
更多推荐
SQL(或Linq)选择以前的值
发布评论