自訂作業:總覽Customizing Operations: Overview

LINQ to SQLLINQ to SQL 預設會根據對應產生動態 SQL,以便進行插入、更新和刪除作業。By default, LINQ to SQLLINQ to SQL generates dynamic SQL for insert, update, and delete operations based on mapping. 但實際上,您通常會想加入自己的業務邏輯,為安全性、驗證等做準備。However, in practice you typically want to add your own business logic to provide for security, validation, and so forth.

LINQ to SQLLINQ to SQL 用於自訂這些作業的技術包括下列項目。techniques for customizing these operations include the following.

載入選項Loading Options

在查詢中,您可以控制在您連接至資料庫時要擷取多少與主要目標相關的資料。In your queries, you can control how much data related to your main target is retrieved when you connect to the database. 這項功能大部分是使用 DataLoadOptions 來實作。This functionality is implemented largely by using DataLoadOptions. 如需詳細資訊,請參閱 < 延後執行與立即載入For more information, see Deferred versus Immediate Loading.

部分方法Partial Methods

在其預設對應中,LINQ to SQLLINQ to SQL 提供了部分方法來協助您實作商務邏輯。In its default mapping, LINQ to SQLLINQ to SQL provides partial methods to help you implement your business logic. 如需詳細資訊,請參閱 < 新增商務邏輯所使用部分方法For more information, see Adding Business Logic By Using Partial Methods.

預存程序和使用者定義的函式Stored Procedures and User-Defined Functions

LINQ to SQLLINQ to SQL 支援使用預存程序和使用者定義函式。supports the use of stored procedures and user-defined functions. 預存程序時常用於自訂作業。Stored procedures are frequently used to customize operations. 如需詳細資訊,請參閱預存程序For more information, see Stored Procedures.

另請參閱See also