查詢資料庫Querying the Database

這組主題描述如何在 LINQ to SQLLINQ to SQL 專案中開發和執行查詢。This group of topics describes how to develop and execute queries in LINQ to SQLLINQ to SQL projects.

本節內容In This Section

如何:如需資訊的查詢How to: Query for Information
簡短顯示 LINQ to SQLLINQ to SQL 查詢一般基本上與 LINQLINQ 查詢相同的程度。Briefly shows how LINQ to SQLLINQ to SQL queries are basically the same as LINQLINQ queries generally.

如何:以唯讀形式擷取資訊How to: Retrieve Information As Read-Only
描述如何在未計劃變更資料的情況下增加查詢效能。Describes how to increase query performance when no change to the data is planned.

如何:控制擷取的相關的資料多寡How to: Control How Much Related Data Is Retrieved
描述如何控制哪些相關資料要與主要目標一起擷取。Describes how to control which related data is retrieved together with the main target.

如何:篩選相關的資料How to: Filter Related Data
描述如何使用子查詢來擷取相關資料。Describes how to retrieve related data by using a sub-query.

如何:關閉延後載入How to: Turn Off Deferred Loading
描述如何關閉延後載入。Describes how to turn off deferred loading.

如何:直接執行 SQL 查詢How to: Directly Execute SQL Queries
描述如何使用 SQL 語言來送出查詢。Describes how to submit queries by using SQL language.

如何:儲存和重複使用查詢How to: Store and Reuse Queries
描述如何只編譯一次查詢,但多次將它與不同參數搭配使用。Describes how to compile a query one time but use it multiple times with different parameters.

如何:處理查詢中的複合索引鍵How to: Handle Composite Keys in Queries
描述如何在查詢中包括多個資料行,而在這個查詢中,運算子只取用單一引數。Describes how to include more than one column in a query where the operator takes only a single argument.

如何:一次擷取多個物件How to: Retrieve Many Objects At Once
說明如何使用 LoadWithDescribes how to use LoadWith.

如何:在 DataContext 層級篩選How to: Filter at the DataContext Level
描述另一種 LoadWith 使用方式。Describes another use of LoadWith.

查詢範例Query Examples
提供查詢的許多範例。Provides many examples of queries.