从ILIST检索单个记录 [英] Retrieving the single record from ILIST
问题描述
大家好,
我正在尝试在C#和ASP.net中创建2个函数
我有一张桌子,上面有大约50条记录.我有一列包含整数的列,可以说50降至0.
所以我创建了一个ILIST,但是我需要一个最接近0的休眠语句来代替foreach语句.我有一个获取ILIST并对其进行相应排序的休眠语句.所以现在我只需要拉第一个记录最接近0的记录即可.
我还需要使用保存截止日期的列对截止日期为今天的记录进行同样的操作.
从来没有做过,所以任何帮助和详细说明都将是有益的
任何帮助都将不胜感激???
感谢所有人.
您可以检索已排序列表的第一个元素.
要对
IList
的元素进行排序,可以使用 OrderBy 方法. /p>
要检索
IList
的第一个元素,可以使用第一个或 FirstOrDefault 方法.
Hello all,
I am trying to create 2 functions in C# and ASP.net
I have a table which has about 50 records. I has a column that hold integer let say 50 down to 0.
So i created an ILIST but instead of foreach statement I need the one that is closest to 0. I have the hibernate statement that gets the ILIST and sort them accordingly. So now I need to only pull the first record the one closest to 0.
I also need to due the same with a record closest to today date using a column that hold a due date.
Never did this before so any help and detailed instruction would be helpfull
Any and all help please will be appreciated????
Thanks to all.
You can retrieve the first element of the sorted list.
For sorting the elements of an
IList
you can use the OrderBy method.
For retrieving the first element of an
IList
you can use the First or the FirstOrDefault methods.
这篇关于从ILIST检索单个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!