Avatar of Kelly Martens
Kelly Martens

asked on 

Pass LINQ where clause as Parameter

It really is a simple question yet finding so much trouble with Google finding how to do it. After the where clause I want to return the results from my strongly typed dataset table with a parameter passed from a parameter with vb.net and how to call it. If you can assist I would appreciate it.

Bolded is where I think it should go. But I clearly don't know how to say it. "test" would be something like
"row.Item(columnname) IsNot DBNull.Value AndAlso row.Item(columnname) = filter AndAlso row.TT_Rec_ID = Template_ID" just for example. But the way I see it we should be able to pass anything through that is LINQ compatible.

Function Global_Table_Query([b]ByVal test As Predicate(Of ds2.JOINEDDATADataTable[/b])) As DataTable
        ErrorMessage = ""

        Dim dt As New DataTable
        Dim Is_Good As Byte = 1
               Dim thread As New Task(

          Dim lowNums = From row In Global_Table
                        [b]Where test
[/b]                        Select row

          dt = lowNums.CopyToDataTable
                    Return dt
      Catch ex As Exception
          ErrorMessage = ex.Message
          Return Nothing

      End Try
  End Function

        Dim tasks() = {thread}
        Array.ForEach(tasks, Sub(tx) tx.Start())

        For Each tsk In tasks

            Select Case True

                Case tsk.IsCanceled
                    Is_Good = 1

                Case tsk.IsFaulted
                    Is_Good = 1

                Case tsk.IsCompleted
                    Is_Good = 0

                Case Else
                    Is_Good = 1

            End Select

        tasks = Nothing
        thread = Nothing

        'checking if something went wrong
        If ErrorMessage <> "" Then
            Is_Good = Nothing
            Return Nothing
        End If
        Return dt

    End Function

Open in new window

Visual Basic.NET* ADO.NetC#Microsoft SQL ServerLINQ Query

Avatar of undefined
Last Comment
Kelly Martens

8/22/2022 - Mon