Bewerken

Delen via


MetaModel.GetModel(Type) Method

Definition

Returns the data-model instance for the specified context.

public:
 static System::Web::DynamicData::MetaModel ^ GetModel(Type ^ contextType);
public static System.Web.DynamicData.MetaModel GetModel (Type contextType);
static member GetModel : Type -> System.Web.DynamicData.MetaModel
Public Shared Function GetModel (contextType As Type) As MetaModel

Parameters

contextType
Type

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

Returns

The data model that is associated with the specified context type.

Examples

The following example shows how to use the GetModel(Type) method to perform the following tasks:

  • Getting the default data model.

  • Getting the data model specified by the passed context type.

For a complete example, see the MetaModel class overview.

// Get the data model. 
public MetaModel GetModel(bool defaultModel)
{
    MetaModel model;

    if (defaultModel)
        model = MetaModel.Default;
    else
        model =
           MetaModel.GetModel(typeof(AdventureWorksLTDataContext));
    return model;
}
' Get the data model. 
Public Function GetModel(ByVal defaultModel As Boolean) As MetaModel
    Dim model As MetaModel

    If defaultModel Then
        model = MetaModel.[Default]
    Else
        model = MetaModel.GetModel(GetType(AdventureWorksLTDataContext))
    End If
    Return model
End Function

Applies to