views:

298

answers:

2

Anyone have experience with compiled query syntax for VB? I'm used them a few times in C#, but can't seem to make the translation. My code is below:

#Region "Locals"
    'Data context objects '
    Private _dbOrderInfo As New OrderInfoDataContext
#End Region

#Region "Delegates"
    Public Shared ReadOnly Func(_dbOrderInfo, Boolean, IQueryable(Of SalesRep))
#End Region

#Region "Compiled Queries"
    Public Shared Function(Of _dbOrderInfo, boolean, IQueryable(Of SalesRep)) _      
                        SalesRepsByStatus = CompiledQuery.Compile( _
                            Function(db As _dbOrderInfo, active As Boolean) _
                            From sr In db.tblSU4SalesRep Where sr.Active = active)
    End Function
#End Region
A: 

Ironically enough, that's the page I copied the code block from.

Oh... you're right, I missed that. Then I'm sorry, but I don't think I can help you...
Banang
A: 

In your code it looks like you are refering to the instance _dbOrderInfo in your method parameters rather than the type (OrderInfoDataContext). See if it works by refering to the type instead. Also, you might want to check out www.thinqlinq.com/Default/LINQ-to-SQL-Compiled-Queries.aspx.

Jim

Jim Wooley