CompiledQuery Class

 

Represents a cached LINQ to Entities query.

Namespace:   System.Data.Objects
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

System.Object
  System.Data.Objects.CompiledQuery

Public NotInheritable Class CompiledQuery

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult)(Expression(Of Func(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult)(Expression(Of Func(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult)(Expression(Of Func(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult)(Expression(Of Func(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult)(Expression(Of Func(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult)(Expression(Of Func(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult)(Expression(Of Func(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TResult)(Expression(Of Func(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TResult)(Expression(Of Func(Of TArg0, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TResult)(Expression(Of Func(Of TArg0, TArg1, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TArg2, TResult)(Expression(Of Func(Of TArg0, TArg1, TArg2, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TArg2, TArg3, TResult)(Expression(Of Func(Of TArg0, TArg1, TArg2, TArg3, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TArg2, TArg3, TArg4, TResult)(Expression(Of Func(Of TArg0, TArg1, TArg2, TArg3, TArg4, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TResult)(Expression(Of Func(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult)(Expression(Of Func(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodSystem_CAPS_staticCompile(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult)(Expression(Of Func(Of TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult)))

Creates a new delegate that represents the compiled LINQ to Entities query.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

Provides for compilation and caching of queries for reuse. Conceptually this class contains a single Compile method with several overloads. You call the Compile method to create a new delegate to represent the compiled query. The delegate, when invoked with the ObjectContext input parameter and other parameter values, produces some result (such as an IQueryable(Of T) instance). The query is translated and cached when the delegate is invoked for the first time.

The following example compiles and then invokes a query that accepts DateTime and Decimal input parameters and returns a sequence of orders where the order date is later than March 8, 2003 and the total due is less than $300.00:

ReadOnly s_compQuery5 = _
   CompiledQuery.Compile(Of AdventureWorksEntities, DateTime, Decimal, IQueryable(Of SalesOrderHeader))( _
                Function(ctx, orderDate, totalDue) From product In ctx.SalesOrderHeaders _
                                                   Where product.OrderDate > orderDate _
                                                      And product.TotalDue < totalDue _
                                                   Order By product.OrderDate _
                                                   Select product)
Sub CompiledQuery5()

    Using context As New AdventureWorksEntities()

        Dim orderedAfterDate As DateTime = New DateTime(2003, 3, 8)
        Dim amountDue As Decimal = 300.0

        Dim orders As IQueryable(Of SalesOrderHeader) = _
            s_compQuery5.Invoke(context, orderedAfterDate, amountDue)

        For Each order In orders
            Console.WriteLine("ID: {0} Order date: {1} Total due: {2}", _
                              order.SalesOrderID, order.OrderDate, order.TotalDue)
        Next

    End Using
End Sub

.NET Framework
Available since 3.5

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: