【发布时间】:2013-11-28 07:05:25
【问题描述】:
我的列表中有 5 个数据。
我的列表
所以我想知道,我怎样才能获得选定的 Id 的行号?
var MyProductId= 135;
var SelectedDataRowNumber = context.SP_MyList.ToList()
.Where(s=>s.Id==MyProductId)
.FirstOrDefault();
例如, 我的列表有 5 个数据,如下所示,
Id-Name
6,Computer
135,KeyBoard
68,Mouse
98,Telephone
213,Laptop,
MyProductId 是135,所以它与键盘匹配。它是行数(索引)必须为“1”,因为 0 是计算机。
如何获取所选 ID 的行数(索引)?
【问题讨论】:
-
行号是什么意思?您能否添加一些示例数据,说明您列表中的对象是什么样的?
-
我更新了请检查
标签: c# entity-framework