MetaModel 构造函数

定义

实例化 MetaModel 类的新实例。Instantiates a new instance of the MetaModel class.

重载

MetaModel()

实例化 MetaModel 类的新实例。Instantiates a new instance of the MetaModel class.

MetaModel(Boolean)

实例化 MetaModel 类的新实例。Instantiates a new instance of the MetaModel class.

MetaModel()

实例化 MetaModel 类的新实例。Instantiates a new instance of the MetaModel class.

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

示例

下面的示例演示如何使用 MetaModel 构造函数执行以下任务:The following example shows how to use the MetaModel constructor to perform the following tasks:

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})

注解

通常 MetaModel 在 global.asax 文件的方法中调用构造函数 Application_StartYou typically call the MetaModel constructor in the Application_Start method of the Global.asax file.

适用于

MetaModel(Boolean)

实例化 MetaModel 类的新实例。Instantiates a new instance of the MetaModel class.

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 指示模型是全局注册的,否则为 falsetrue to indicate that the model is registered globally; otherwise false. 默认值为 trueThe default is true.

注解

此构造函数确定数据模型是否是全局注册的,以便可以使用方法检索它 GetModelThis constructor determines whether the data model is registered globally so that it can be retrieved using the GetModel method. 它使您能够创建多个模型并使用相同的实体类型,同时避免类型冲突。It enables you to create multiple models and use the same entity types while avoiding type conflicts.

通常 MetaModel 在 global.asax 文件的方法中调用构造函数 Application_StartYou typically call the MetaModel constructor in the Application_Start method of the Global.asax file.

适用于