LINQ - VB.net中编译的查询

时间:2009-04-07 20:37:59

标签: .net vb.net linq linq-to-sql

有没有经验丰富的VB编译查询语法?我在C#中使用了几次,但似乎无法进行翻译。我的代码如下:

#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

1 个答案:

答案 0 :(得分:0)

在您的代码中,您似乎在引用方法参数中的实例_dbOrderInfo而不是类型(OrderInfoDataContext)。通过引用类型来查看它是否有效。此外,您可能需要查看this