ScaffoldColumnAttribute 類別

定義

指定類別或資料行是否使用 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 設定為 ,以公開 AdventureWorksLT 資料基底中 Products 資料表的 ProductID 資料行。 它會將 Scaffold 屬性套用至 ThumbnailPhotoFileName 物件,並將其設定為 false ,以隱藏 ThumbnailPhotoFileName 資料行。

[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  

若要編譯這段範例程式碼,您需要下列項目:

  • 任何版本的 Visual Studio 2010 或更新版本。

  • AdventureWorksLT 範例資料庫。 如需如何下載並安裝SQL Server範例資料庫的資訊,請參閱Microsoft SQL Server 產品範例:GitHub 上的資料庫。 請確定您為所執行SQL Server版本安裝正確的範例資料庫版本。

  • 動態資料網站。 這可讓您為資料庫和類別建立資料內容,其中包含要自訂的資料欄位,以及要覆寫的方法。 此外,它會建立使用之前所述的頁面的環境。 如需詳細資訊,請參閱 逐步解說:使用 Scaffolding 建立新的動態資料網站

備註

Scaffolding 是根據資料庫架構產生網頁範本的機制。 ASP.NET 動態資料會使用 Scaffolding 來產生 Web 型 UI,讓使用者檢視和更新資料庫。 這個類別會 Scaffold 使用 屬性在動態資料網站中啟用 Scaffolding。

Scaffolding 會根據資料模型動態顯示頁面,而不需要實體頁面,藉此增強 ASP.NET 網頁架構。

Scaffolding 提供下列功能:

  • 建立資料驅動 Web 應用程式的最少或沒有任何程式碼。

  • 快速開發時間。

  • 功能完整的頁面,包括顯示、插入、編輯、刪除、排序和分頁功能。

  • 以資料庫架構為基礎的內建資料驗證。

  • 針對每個外鍵或布林值欄位所建立的篩選。

這個類別可用來啟用或停用資料模型中資料行的 Scaffolding,方法是將此屬性套用至代表資料表之類別中的適當資料欄位物件。

建構函式

ScaffoldColumnAttribute(Boolean)

使用 ScaffoldColumnAttribute 屬性,初始化 Scaffold 的新執行個體。

屬性

Scaffold

取得或設定值,這個值指定是否啟用 Scaffolding。

TypeId

在衍生類別中實作時,取得這個 Attribute 的唯一識別碼。

(繼承來源 Attribute)

方法

Equals(Object)

傳回值,這個值指出此執行個體是否與指定的物件相等。

(繼承來源 Attribute)
GetHashCode()

傳回這個執行個體的雜湊碼。

(繼承來源 Attribute)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IsDefaultAttribute()

在衍生類別中覆寫時,表示這個執行個體的值是衍生類別的預設值。

(繼承來源 Attribute)
Match(Object)

在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。

(繼承來源 Attribute)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

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

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

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

擷取物件的類型資訊,可以用來取得介面的類型資訊。

(繼承來源 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。

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

提供物件所公開的屬性和方法的存取權。

(繼承來源 Attribute)

適用於