MetaModel 建構函式

定義

執行個體化 MetaModel 類別的新執行個體。

多載

MetaModel()

執行個體化 MetaModel 類別的新執行個體。

MetaModel(Boolean)

執行個體化 MetaModel 類別的新執行個體。

MetaModel()

執行個體化 MetaModel 類別的新執行個體。

public:
 MetaModel();
public MetaModel ();
Public Sub New ()

範例

下列範例示範如何使用 建 MetaModel 構函式來執行下列工作:

MetaModel model = new MetaModel();
model.RegisterContext(typeof(AdventureWorksLTDataContext), 
    new ContextConfiguration() { ScaffoldAllTables = true });
Dim model As New MetaModel
model.RegisterContext(GetType(AdventureWorksLTDataContext), _
   New ContextConfiguration() With {.ScaffoldAllTables = True})

備註

您通常會在 Global.asax 檔案的 方法中 Application_Start 呼叫 MetaModel 建構函式。

適用於

MetaModel(Boolean)

執行個體化 MetaModel 類別的新執行個體。

public:
 MetaModel(bool registerGlobally);
public MetaModel (bool registerGlobally);
new System.Web.DynamicData.MetaModel : bool -> System.Web.DynamicData.MetaModel
Public Sub New (registerGlobally As Boolean)

參數

registerGlobally
Boolean

true 表示已全域註冊該模型,否則為 false。 預設為 true

備註

此建構函式會判斷資料模型是否已全域註冊,以便使用 GetModel 方法擷取資料模型。 它可讓您建立多個模型,並使用相同的實體類型,同時避免類型衝突。

您通常會在 Global.asax 檔案的 方法中 Application_Start 呼叫 MetaModel 建構函式。

適用於