Share via


DbRawSqlQuery 類別

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

表示非實體的 SQL 查詢,該查詢是從 DbContext 建立而且會使用該內容中的連接來執行。 此類別的執行個體會從 Database 執行個體取得。 建立此物件時不會執行此查詢,每當列舉此查詢時便會執行,例如,藉由使用 foreach。 實體的 SQL 查詢會使用 SqlQuery(String, Object[]) 加以建立。 請參閱 DbRawSqlQuery<TElement> 以取得此類別的泛型版本。

繼承階層

System.Object
  System.Data.Entity.Infrastructure.DbRawSqlQuery
    System.Data.Entity.Infrastructure.DbSqlQuery

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

語法

'宣告
<SuppressMessageAttribute("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")> _
<SuppressMessageAttribute("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")> _
Public Class DbRawSqlQuery _
    Implements IEnumerable, IListSource, IDbAsyncEnumerable
'用途
Dim instance As DbRawSqlQuery
[SuppressMessageAttribute("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
[SuppressMessageAttribute("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
public class DbRawSqlQuery : IEnumerable, 
    IListSource, IDbAsyncEnumerable
[SuppressMessageAttribute(L"Microsoft.Naming", L"CA1710:IdentifiersShouldHaveCorrectSuffix")]
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1010:CollectionsShouldImplementGenericInterface")]
public ref class DbRawSqlQuery : IEnumerable, 
    IListSource, IDbAsyncEnumerable
[<SuppressMessageAttribute("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")>]
[<SuppressMessageAttribute("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")>]
type DbRawSqlQuery =  
    class 
        interface IEnumerable 
        interface IListSource 
        interface IDbAsyncEnumerable 
    end
public class DbRawSqlQuery implements IEnumerable, IListSource, IDbAsyncEnumerable

DbRawSqlQuery 類型會公開下列成員。

方法

  名稱 描述
公用方法 AsStreaming 已過時。 傳回會串流結果而非緩衝處理的新查詢。
公用方法 Equals 指定此查詢是否與指定的物件相等。 (覆寫 Object.Equals(Object)。)
受保護的方法 Finalize (繼承自 Object)。
公用方法 ForEachAsync(Action<Object>) 非同步列舉查詢結果,並針對每個項目執行指定動作。
公用方法 ForEachAsync(Action<Object>, CancellationToken) 非同步列舉查詢結果,並針對每個項目執行指定動作。
公用方法 GetEnumerator 傳回 IEnumerator,其在列舉時會對資料庫執行 SQL 查詢。
公用方法 GetHashCode 取得與此查詢相關聯的雜湊碼。 (覆寫 Object.GetHashCode()。)
公用方法 GetType 取得與此查詢相關聯的類型。
受保護的方法 MemberwiseClone (繼承自 Object)。
公用方法 ToListAsync() 透過列舉以非同步方式從查詢建立 List<T>
公用方法 ToListAsync(CancellationToken) 透過列舉以非同步方式從查詢建立 List<T>
公用方法 ToString 傳回 String,其中包含建立查詢時所設定的 SQL 字串。不包含參數。 (覆寫 Object.ToString()。)

靠上

明確介面實作

  名稱 描述
明確介面實作私用屬性 IListSource.ContainsListCollection 傳回 false。
明確介面實作私用方法 IListSource.GetList 擲回例外狀況,表示不支援直接繫結至存放區查詢。
明確介面實作私用方法 IDbAsyncEnumerable.GetAsyncEnumerator 傳回 IDbAsyncEnumerable,其在列舉時會對資料庫執行 SQL 查詢。

靠上

執行緒安全

這個類型的任何 Public static (在 Visual Basic 中為 Shared) 成員都是安全執行緒。並非所有的執行個體成員都是安全執行緒。

請參閱

參考

System.Data.Entity.Infrastructure 命名空間