ScaffoldTableAttribute 類別


指定類別或資料的資料表 (Data Table) 是否使用 Scaffolding。Specifies whether a class or data table uses scaffolding.

public ref class ScaffoldTableAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false)]
public class ScaffoldTableAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false)>]
type ScaffoldTableAttribute = class
    inherit Attribute
Public Class ScaffoldTableAttribute
Inherits Attribute


下列程式碼範例會將 scaffold 屬性套用至代表錯誤記錄資料表的錯誤記錄部分類別,以隱藏 AdventureWorksLT 資料庫中的錯誤記錄資料表。The following code example hides the ErrorLog Table in AdventureWorksLT database by applying the scaffold attribute to the ErrorLog partial class that represents the ErrorLog table. Scaffold 屬性設定為 false.The scaffold property is set to false.

[MetadataType (typeof(ErrorLogMetadata))]  
public partial class ErrorLog  


public class ErrorLogMetadata  

<MetadataType(GetType(ErrorLogMetadata))> _   
Public Partial Class ErrorLog   

End Class   

Public Class ErrorLogMetadata  

End Class   

若要編譯這段範例程式碼,您需要下列項目:To compile the example code, you need the following:

  • Visual Studio 2008 Service Pack 1 或 Visual Developer 2008 Express Edition Service Pack 1。Visual Studio 2008 Service Pack 1 or Visual Developer 2008 Express Edition Service Pack 1.

  • AdventureWorksLT 範例資料庫。The AdventureWorksLT sample database. 如需有關如何下載及安裝 SQL Server 範例資料庫的詳細資訊,請參閱 Microsoft SQL Server 產品範例: GitHub 上的資料庫。For information about how to download and install the SQL Server sample database, see Microsoft SQL Server Product Samples: Database on GitHub. 確定您已針對您正在執行的 SQL Server 版本安裝正確版本的範例資料庫。Make sure that you install the correct version of the sample database for the version of SQL Server that you are running.

  • 動態資料的網站。A Dynamic Data Web site. 這可讓您建立資料庫的資料內容,以及包含要自訂之資料欄位的類別,以及要覆寫的方法。This enables you to create a data context for the database and the class that contains the data field to customize and the methods to override. 此外,它還會建立要在其中使用先前所述頁面的環境。In addition, it creates the environment in which to use the page described before. 如需詳細資訊,請參閱 逐步解說:使用樣板建立新的動態資料網站For more information, see Walkthrough: Creating a New Dynamic Data Web Site Using Scaffolding.


「架構」(樣板)是根據資料庫架構產生網頁範本的機制。Scaffolding is the mechanism for generating web page templates based on database schemas. ASP.NET 動態資料會使用樣板來產生 Web 型 UI,讓使用者能夠查看和更新資料庫。ASP.NET Dynamic Data uses scaffolding to generate Web-based UI that lets a user to view and update a database. 這個類別會使用 Scaffold 屬性來啟用動態資料網站中個別資料表的樣板。This class uses the Scaffold property to enable scaffolding of individual tables in a Dynamic Data Web Site. 藉由動態顯示以資料模型為基礎的頁面,而不需要實體頁面,即可增強 ASP.NET 網頁架構。Scaffolding enhances the ASP.NET page framework by dynamically displaying pages based on the data model with no physical pages required.

樣板提供下列各項:Scaffolding provides the following:

  • 建立資料驅動 Web 應用程式的基本或無程式碼。Minimal or no code to create a data-driven Web application.

  • 快速開發時間。Quick development time.

  • 可完全正常運作的頁面,包括顯示、插入、編輯、刪除、排序和分頁功能。Pages that are fully functional, including display, insert, edit, delete, sorting, and paging functionalities.

  • 以資料庫架構為基礎的內建資料驗證。Built-in data validation based on the database schema.

  • 針對每個外鍵或布林值欄位建立的篩選準則。Filters that are created for each foreign key or Boolean fields.

這個類別可用來啟用或停用資料模型中的資料表的樣板,方法是將此屬性套用至代表該資料表的部分類別。This class can be used to enable or disable scaffolding of data tables in a data model by applying this attribute to the partial class that represents the table.



使用 ScaffoldTableAttribute 屬性,初始化 Scaffold 的新執行個體。Initializes a new instance of ScaffoldTableAttribute using the Scaffold property.



取得或設定值,這個值指定是否啟用 Scaffolding。Gets or sets the value that specifies whether scaffolding is enabled.


在衍生類別中實作時,取得這個 Attribute 的唯一識別碼。When implemented in a derived class, gets a unique identifier for this Attribute.

(繼承來源 Attribute)



傳回值,這個值指出此執行個體是否與指定的物件相等。Returns a value that indicates whether this instance is equal to a specified object.

(繼承來源 Attribute)

傳回這個執行個體的雜湊碼。Returns the hash code for this instance.

(繼承來源 Attribute)

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)

在衍生類別中覆寫時,表示這個執行個體的值是衍生類別的預設值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(繼承來源 Attribute)

在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(繼承來源 Attribute)

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)


_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。Maps a set of names to a corresponding set of dispatch identifiers.

(繼承來源 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。Retrieves the type information for an object, which can be used to get the type information for an interface.

(繼承來源 Attribute)

擷取物件提供的類型資訊介面數目 (0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(繼承來源 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開的屬性和方法的存取權。Provides access to properties and methods exposed by an object.

(繼承來源 Attribute)