是否可以将此功能缩短为一行/几行?
Public Function countrySelector() As List(Of String)
Dim myString As New List(Of String)
Dim countryTitle As List(Of Entities.AttributeValue) = _PageVals.Where(Function(x) x.TabDescription = "Country").ToList()
myString = countryTitle.Where(Function(x) x.AttributeId = Entities.AttributeTypes.TITLE).Select(Function(y) y.Value).ToList()
Return myString
End Function
答案 0 :(得分:2)
试试这个,
myString = _PageVals.Where(Function(x) x.TabDescription = "Country" AndAlso x.AttributeId = Entities.AttributeTypes.TITLE).Select(Function(y) y.Value).ToList()
答案 1 :(得分:1)
尝试以下
Return _PageVals _
.Where(Function(x) x.TabDescription = "Country") _
.Where(Function(x) x.AttributeId = Entities.AttributeTypes.TITLE) _
.Select(Function(y) y.Value) _
.ToList()
答案 2 :(得分:0)
或者你可以这样使用
myString = (From C in _PageVals Where C.TabDescription = "Country" AndAlso C.AttributeId = Entities.AttributeTypes.TITLE Select C.Value).ToList()