共用方式為


CompiledQuery.Compile<TArg0, TResult> 方法 (Expression<Func<TArg0, TResult>>)

[此頁面專屬於 Entity Framework 第 6 版。最新版本可從 'Entity Framework' NuGet 套件取得。如需 Entity Framework 的詳細資訊,請參閱 msdn.com/data/ef。]

建立新委派以表示編譯的 LINQ to Entities 查詢。

命名空間:  System.Data.Entity.Core.Objects
組件:  EntityFramework (在 EntityFramework.dll 中)

語法

'宣告
<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")> _
<SuppressMessageAttribute("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification := "required for this feature")> _
Public Shared Function Compile(Of TArg0 As ObjectContext, TResult) ( _
    query As Expression(Of Func(Of TArg0, TResult)) _
) As Func(Of TArg0, TResult)
'用途
Dim query As Expression(Of Func(Of TArg0, TResult))
Dim returnValue As Func(Of TArg0, TResult)

returnValue = CompiledQuery.Compile(query)
[SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
[SuppressMessageAttribute("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "required for this feature")]
public static Func<TArg0, TResult> Compile<TArg0, TResult>(
    Expression<Func<TArg0, TResult>> query
)
where TArg0 : ObjectContext
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1006:DoNotNestGenericTypesInMemberSignatures")]
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1011:ConsiderPassingBaseTypesAsParameters", Justification = L"required for this feature")]
public:
generic<typename TArg0, typename TResult>
where TArg0 : ObjectContext 
static Func<TArg0, TResult>^ Compile(
    Expression<Func<TArg0, TResult>^>^ query
)
[<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")>]
[<SuppressMessageAttribute("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "required for this feature")>]
static member Compile : 
        query:Expression<Func<'TArg0, 'TResult>> -> Func<'TArg0, 'TResult>  when 'TArg0 : ObjectContext
JScript does not support generic types and methods.

類型參數

  • TResult
    查詢結果的類型 T,這些查詢結果是由執行 Compile<TArg0, TResult>(Expression<Func<TArg0, TResult>>) 方法所傳回的委派而傳回。

參數

傳回值

類型:System.Func<TArg0, TResult>
Func<T, TResult> ,表示編譯的 LINQ to Entities 查詢的泛型委派。

請參閱

參考

CompiledQuery 類別

Compile 多載

System.Data.Entity.Core.Objects 命名空間