VB.NET LINQ如何连接一个Select

时间:2013-05-07 18:42:58

标签: vb.net linq

 Dim placesOfServces =  From x In tbl_pos _
                        Where x.active = True _
                        Select  x.pos_id, x.pos_code & " - " & x.pos_desc

获取错误

  

范围变量名称只能从没有参数的简单或限定名称推断。

问题,需要返回x.pos_codex.pos_desc的串联字符串。帮助必须在VB.NET中。

2 个答案:

答案 0 :(得分:2)

Dim placesOfServces =  From x In tbl_pos _
                        Where x.active = True _
                        Select New With {.Pos_id= x.pos_id , .CodeDesc = x.pos_code & " - " & x.pos_desc}

答案 1 :(得分:1)

试试这样:

 Dim placesOfServces =  From x In tbl_pos _                                       
                       Where x.active = True _
                       Let cc = x.pos_code & " - " & x.pos_desc   
                       Select  x.pos_id, cc