Senhores se possível alguém poderia me dizer como ficaria esta função usando linq
Public Function fRodaQuery(ByVal fSc As String, Optional ByVal fCodigoMenu As Integer = 0, _
Optional ByVal fNomeMenu As String = "", Optional ByVal fCodigoModulo As Integer = 0, _
Optional ByVal fWhere As String = "", Optional ByVal fOrder As String = "",optional fEnulo as boolean=false) As DataSet
Dim vsApoio As String = " where "
Dim voUtil As New utilRotinas
Dim vsSql As String = "select *,menu_cod as codigo,menu_nome as descricao from ace_menu"
Dim voCnn As NpgsqlConnection = voUtil.fConecta(fSc)
Dim voCmd As NpgsqlCommand = New NpgsqlCommand(vsSql, voCnn)
Try
If fCodigoMenu > 0 Then
voCmd.CommandText &= vsApoio & "menu_cod= :menu_cod"
voUtil.setParametro(voCmd, "menu_cod", NpgsqlTypes.NpgsqlDbType.Integer, fCodigoMenu)
vsApoio = " and "
End If
If Len(Trim(fNomeMenu)) > 0 Then
voCmd.CommandText &= vsApoio & "menu_nome= :menu_nome"
voUtil.setParametro(voCmd, "menu_nome", NpgsqlTypes.NpgsqlDbType.Varchar, fNomeMenu.ToLower)
vsApoio = " and "
End If
If fCodigoModulo > 0 Then
voCmd.CommandText &= vsApoio & "mod_cod= :mod_cod"
voUtil.setParametro(voCmd, "mod_cod", NpgsqlTypes.NpgsqlDbType.Integer, fCodigoModulo)
vsApoio = " and "
End If
If fCodigoNivelSuperior > 0 Then
voCmd.CommandText &= vsApoio & "menu_cod_pai= :menu_cod_pai"
voUtil.setParametro(voCmd, "menu_cod_pai", NpgsqlTypes.NpgsqlDbType.Integer, fCodigoNivelSuperior)
vsApoio = " and "
End If
if fenulo then
voCmd.CommandText &= vsApoio & " " & "menu_acao is null"
endif
'fwhere terá + condições para a clausula where
If Len(Trim(fWhere)) > 0 Then voCmd.CommandText &= vsApoio & " " & LCase(fWhere)
If Len(Trim(fOrder)) = 0 Then
voCmd.CommandText &= " order by descricao "
Else
voCmd.CommandText &= " order by " & fOrder & " "
End If
Dim voDs As New DataSet
Dim voDa As NpgsqlDataAdapter = New NpgsqlDataAdapter(voCmd)
voDa.Fill(voDs, "tabela")
Return voDs
Catch ex As Exception
Throw ex
Finally
voUtil.fDesConecta(voCnn)
End Try
End Function
t+