ScaffoldColumnAttribute 類別

定義

指定類別或資料行是否使用 Scaffolding。Specifies whether a class or data column uses scaffolding.

public ref class ScaffoldColumnAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false)]
public class ScaffoldColumnAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false)>]
type ScaffoldColumnAttribute = class
    inherit Attribute
Public Class ScaffoldColumnAttribute
Inherits Attribute
繼承
ScaffoldColumnAttribute
屬性

範例

下列程式碼範例會將 scaffold 屬性套用至 Products 部分類別中的 ProductID 物件,並將它設定為,藉 true. 由將 scaffold 屬性套用至 ThumbnailPhotoFileName 物件,並將其設定為,藉以公開 AdventureWorksLT 資料基底中 products 資料表的 productid 資料行 falseThe following code example exposes the ProductID column of the Products table in the AdventureWorksLT data base by applying the scaffold property to the ProductID object in the Products partial class and setting it to true. It hides the ThumbnailPhotoFileName column by applying the scaffold property to the ThumbnailPhotoFileName object and setting it to false.

[MetadataType(typeof(ProductMetadata))]  
public partial class Product  
{  

}  

public class ProductMetadata  
{  
    [ScaffoldColumn(true)]  
    public object ProductID;  

    [ScaffoldColumn(false)]  
    public object ThumbnailPhotoFileName;  

}  
<MetadataType(GetType(ProductMetadata))>  
Public Partial Class Product   

End Class   

Public Class ProductMetadata   
    <ScaffoldColumn(True)>  
    Public ProductID As Object   

    <ScaffoldColumn(False)>   
    Public ThumbnailPhotoFileName As Object  

End Class  

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

  • 任何版本的 Visual Studio 2010 或更新版本。Any edition of Visual Studio 2010 or later.

  • 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 in a Dynamic Data Web Site.

藉由動態顯示以資料模型為基礎的頁面,而不需要實體頁面,即可增強 ASP.NET 網頁架構。Scaffolding enhances ASP.NET page framework by dynamically displaying pages based on the data model with no physical pages required.

樣板提供下列功能:Scaffolding provides the following capabilities:

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

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

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

  • 以資料庫架構為基礎的內建資料驗證。Built-in data validation that is 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 columns in a data model by applying this attribute to the appropriate data field object in the class that represents the table.

建構函式

ScaffoldColumnAttribute(Boolean)

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

屬性

Scaffold

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

TypeId

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

(繼承來源 Attribute)

方法

Equals(Object)

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

(繼承來源 Attribute)
GetHashCode()

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

(繼承來源 Attribute)
GetType()

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

(繼承來源 Object)
IsDefaultAttribute()

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

(繼承來源 Attribute)
Match(Object)

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

(繼承來源 Attribute)
MemberwiseClone()

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

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。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)
_Attribute.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (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)

適用於