从ILIST检索单个记录 [英] Retrieving the single record from ILIST

查看:63
本文介绍了从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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆