Bewerken

Share via


MetaModel.RegisterContext Method

Definition

Registers the data context.

Overloads

RegisterContext(Func<Object>)

Registers the data context that is specified by a context factory.

RegisterContext(Type)

Registers a data-context instance.

RegisterContext(DataModelProvider)

Registers a data context instance by using a data-model provider.

RegisterContext(Func<Object>, ContextConfiguration)

Registers a data-context instance by using the specified context configuration and by enabling a custom constructor.

RegisterContext(Type, ContextConfiguration)

Registers a data-context instance by using the specified context configuration.

RegisterContext(DataModelProvider, ContextConfiguration)

Registers a data-context instance by using the specified context configuration and by enabling a data-model provider.

Remarks

You can define data-context initialization information by using the properties of the ContextConfiguration class.

RegisterContext(Func<Object>)

Registers the data context that is specified by a context factory.

public:
 void RegisterContext(Func<System::Object ^> ^ contextFactory);
public:
 virtual void RegisterContext(Func<System::Object ^> ^ contextFactory);
public void RegisterContext (Func<object> contextFactory);
member this.RegisterContext : Func<obj> -> unit
abstract member RegisterContext : Func<obj> -> unit
override this.RegisterContext : Func<obj> -> unit
Public Sub RegisterContext (contextFactory As Func(Of Object))

Parameters

contextFactory
Func<Object>

The factory for instantiating the data context.

Remarks

This method uses the default context information that is defined by the ContextConfiguration class. It enables you to instantiate the data context by using your own constructor.

Applies to

RegisterContext(Type)

Registers a data-context instance.

public:
 void RegisterContext(Type ^ contextType);
public:
 virtual void RegisterContext(Type ^ contextType);
public void RegisterContext (Type contextType);
member this.RegisterContext : Type -> unit
abstract member RegisterContext : Type -> unit
override this.RegisterContext : Type -> unit
Public Sub RegisterContext (contextType As Type)

Parameters

contextType
Type

The type of the data context as defined in the data model.

Remarks

This method uses the default context information as defined by the ContextConfiguration class.

Applies to

RegisterContext(DataModelProvider)

Registers a data context instance by using a data-model provider.

public:
 void RegisterContext(System::Web::DynamicData::ModelProviders::DataModelProvider ^ dataModelProvider);
public:
 virtual void RegisterContext(System::Web::DynamicData::ModelProviders::DataModelProvider ^ dataModelProvider);
public void RegisterContext (System.Web.DynamicData.ModelProviders.DataModelProvider dataModelProvider);
member this.RegisterContext : System.Web.DynamicData.ModelProviders.DataModelProvider -> unit
abstract member RegisterContext : System.Web.DynamicData.ModelProviders.DataModelProvider -> unit
override this.RegisterContext : System.Web.DynamicData.ModelProviders.DataModelProvider -> unit
Public Sub RegisterContext (dataModelProvider As DataModelProvider)

Parameters

dataModelProvider
DataModelProvider

A provider for the data model.

Applies to

RegisterContext(Func<Object>, ContextConfiguration)

Registers a data-context instance by using the specified context configuration and by enabling a custom constructor.

public:
 void RegisterContext(Func<System::Object ^> ^ contextFactory, System::Web::DynamicData::ContextConfiguration ^ configuration);
public:
 virtual void RegisterContext(Func<System::Object ^> ^ contextFactory, System::Web::DynamicData::ContextConfiguration ^ configuration);
public void RegisterContext (Func<object> contextFactory, System.Web.DynamicData.ContextConfiguration configuration);
member this.RegisterContext : Func<obj> * System.Web.DynamicData.ContextConfiguration -> unit
abstract member RegisterContext : Func<obj> * System.Web.DynamicData.ContextConfiguration -> unit
override this.RegisterContext : Func<obj> * System.Web.DynamicData.ContextConfiguration -> unit
Public Sub RegisterContext (contextFactory As Func(Of Object), configuration As ContextConfiguration)

Parameters

contextFactory
Func<Object>

A delegate that is used to instantiate the data model context.

configuration
ContextConfiguration

The context information as defined by the ContextConfiguration class.

Exceptions

contextFactory is null.

The contextType that is instantiated by contextFactory is not valid.

Remarks

The context factory in this method enables you to instantiate a data model context by using a custom constructor.

Applies to

RegisterContext(Type, ContextConfiguration)

Registers a data-context instance by using the specified context configuration.

public:
 void RegisterContext(Type ^ contextType, System::Web::DynamicData::ContextConfiguration ^ configuration);
public:
 virtual void RegisterContext(Type ^ contextType, System::Web::DynamicData::ContextConfiguration ^ configuration);
public void RegisterContext (Type contextType, System.Web.DynamicData.ContextConfiguration configuration);
member this.RegisterContext : Type * System.Web.DynamicData.ContextConfiguration -> unit
abstract member RegisterContext : Type * System.Web.DynamicData.ContextConfiguration -> unit
override this.RegisterContext : Type * System.Web.DynamicData.ContextConfiguration -> unit
Public Sub RegisterContext (contextType As Type, configuration As ContextConfiguration)

Parameters

contextType
Type

The type of the data context as defined in the data model.

configuration
ContextConfiguration

The configuration information for the context, as defined by the ContextConfiguration class.

Exceptions

contextType is null.

Examples

The following example shows how to use the RegisterContext(Type, ContextConfiguration) method to register a data context with scaffolding enabled, as specified by the configuration parameter.

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

Applies to

RegisterContext(DataModelProvider, ContextConfiguration)

Registers a data-context instance by using the specified context configuration and by enabling a data-model provider.

public:
 void RegisterContext(System::Web::DynamicData::ModelProviders::DataModelProvider ^ dataModelProvider, System::Web::DynamicData::ContextConfiguration ^ configuration);
public:
 virtual void RegisterContext(System::Web::DynamicData::ModelProviders::DataModelProvider ^ dataModelProvider, System::Web::DynamicData::ContextConfiguration ^ configuration);
public void RegisterContext (System.Web.DynamicData.ModelProviders.DataModelProvider dataModelProvider, System.Web.DynamicData.ContextConfiguration configuration);
public virtual void RegisterContext (System.Web.DynamicData.ModelProviders.DataModelProvider dataModelProvider, System.Web.DynamicData.ContextConfiguration configuration);
member this.RegisterContext : System.Web.DynamicData.ModelProviders.DataModelProvider * System.Web.DynamicData.ContextConfiguration -> unit
abstract member RegisterContext : System.Web.DynamicData.ModelProviders.DataModelProvider * System.Web.DynamicData.ContextConfiguration -> unit
override this.RegisterContext : System.Web.DynamicData.ModelProviders.DataModelProvider * System.Web.DynamicData.ContextConfiguration -> unit
Public Sub RegisterContext (dataModelProvider As DataModelProvider, configuration As ContextConfiguration)
Public Overridable Sub RegisterContext (dataModelProvider As DataModelProvider, configuration As ContextConfiguration)

Parameters

dataModelProvider
DataModelProvider

A provider for the data model.

configuration
ContextConfiguration

The context information as defined by the ContextConfiguration class.

Exceptions

dataModelProvider or configuration is null.

contextType is already registered.

Applies to