Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help translating LINQ expression tree from C# to VB.net

Status
Not open for further replies.

TheBugSlayer

Programmer
Sep 22, 2002
887
0
0
US
Hi all.
I have a C# code that does this:
Code:
using (TContext dc = new TContext())
                {
                    dc.CommandTimeout = this.CommandTimeout;
                    var result = dc.GetTable<TData>().Where<TData>(criteria).SingleOrDefault();
                    if (result == null)
                        SetNew();
                    else
                        Load(result);
                }
I would like to translate the one line that uses generics and expression trees to VB.NET. This is as far as I am getting
Code:
 Public Sub ExecuteQuery(ByVal critera As Expression(Of Func(Of TData, Boolean)))
        Try
            Dim tbl As Table(Of TData)
            Using dc As TContext = New TContext()
                dc.CommandTimeout = 60
                Dim result = dc.GetTable(Of TData)().Where(Of TData)(criteria).SingleOrDefault()

            End Using
        Catch ex As Exception

        End Try
    End Sub
The syntax is not OK but I don't know how to fix it in this verbose VB.NET language...

Your help is appreciated.


MCP SQL Server 2000, MCTS SQL Server 2005, MCTS SQL Server 2008 (DBD, DBA)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top