如何从列表中获取特定数据?

时间:2015-10-29 06:30:57

标签: asp.net vb.net

我在列表中的表信息()这里tblRole是一个表名表单数据库。在列表中,列表计数为2.现在我想获取每个列表行数据。我不知道如何做到这一点,任何人都可以帮助我。

Dim dbContext As New HREntitiesModel()
Dim searchResult As New List(Of TblUser)
Dim roleSearch As New List(Of TblRole)
Using dbContext
      roleSearch = (From result In dbContext.TblRoles
                        Where result.FldSysName.Contains(newSearchString)
                        Select result).ToList()
      For Each item In roleSearch
              searchResult = (From result In dbContext.TblUsers
                             Where result.FldRoleIDRef = item.FldRoleID AndAlso result.FldUserDeletedDTG Is Nothing
                             Select result).ToList()
      Next
End Using

3 个答案:

答案 0 :(得分:0)

如果你有列表使用简单的forach:

foreach (int item in  List) 
{
    Console.WriteLine(item);
}

答案 1 :(得分:0)

试用此代码:

using (dbContext)
{ 
    roleSearchGuid = (from result in dbContext.TblRoleswhere result.FldSysName.Contains(newSearchString)result); 
    dynamic count = roleSearchGuid.Count; 
    foreach (tblRole tmp in roleSearchGuid) 
    { 

       searchResult = (from result in dbContext.TblUserswhere result.FldRoleIDRef == tmp.FldRoleID && result.FldUserDeletedDTG == nullresult).ToList(); 
    } 
}

答案 2 :(得分:-1)

试试这个。

foreach (tblRole tblRow in  List<tblRole>) 
{
    Console.WriteLine(tblRow.ColumnName);
}

:)