MetaModel.Tables 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
데이터 모델의 일부인 모든 테이블의 컬렉션을 가져옵니다.
public:
property System::Collections::ObjectModel::ReadOnlyCollection<System::Web::DynamicData::MetaTable ^> ^ Tables { System::Collections::ObjectModel::ReadOnlyCollection<System::Web::DynamicData::MetaTable ^> ^ get(); };
public System.Collections.ObjectModel.ReadOnlyCollection<System.Web.DynamicData.MetaTable> Tables { get; }
member this.Tables : System.Collections.ObjectModel.ReadOnlyCollection<System.Web.DynamicData.MetaTable>
Public ReadOnly Property Tables As ReadOnlyCollection(Of MetaTable)
속성 값
데이터 모델에 속한 테이블을 포함하는 컬렉션입니다.
예제
다음 예제에서는 다음 작업을 수행하기 위해 속성 및 VisibleTables 속성을 사용하는 Tables 방법을 보여 줍니다.
데이터 모델의 모든 테이블 컬렉션을 가져와서 컨트롤에
GridView
표시합니다.데이터 모델에서 표시되는 테이블의 컬렉션을 가져와서 컨트롤에
GridView
표시합니다.
이 예제는 페이지와 해당 코드 숨김 파일로 구성됩니다.
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="TablesMenu.aspx.cs"
Inherits="TablesMenu" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<h2>Tables</h2>
<form runat="server">
<h4>Visible Tables</h4>
<asp:GridView ID="Menu1" runat="server"
AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Table Name" SortExpression="TableName">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#Eval("ListActionPath") %>'><%#Eval("DisplayName") %></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<h4>Tables in the Data Model</h4>
<asp:GridView ID="Menu2" runat="server"
AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Table Name" SortExpression="TableName">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#Eval("ListActionPath") %>'><%#Eval("DisplayName") %></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
</body>
<%@ Page Language="VB" AutoEventWireup="true"
CodeFile="TablesMenu.aspx.vb"
Inherits="_TablesMenu" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<h2>Tables</h2>
<form id="Form1" runat="server">
<h4>Visible Tables</h4>
<asp:GridView ID="Menu1" runat="server"
AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Table Name" SortExpression="TableName">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#Eval("ListActionPath") %>'><%#Eval("DisplayName") %></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<h4>Tables in the Data Model</h4>
<asp:GridView ID="Menu2" runat="server"
AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Table Name" SortExpression="TableName">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#Eval("ListActionPath") %>'><%#Eval("DisplayName") %></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
</body>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.DynamicData;
using System.Text;
public partial class TablesMenu : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e) {
GetVisibleTables();
GetTables();
}
// Gets all the tables in the data model.
protected void GetTables()
{
System.Collections.IList tables =
MetaModel.Default.Tables;
if (tables.Count == 0)
{
throw new InvalidOperationException(
"There are no tables in the data model.");
}
Menu2.DataSource = tables;
Menu2.DataBind();
}
// Gets only the visible tables in the data model.
protected void GetVisibleTables()
{
System.Collections.IList visibleTables =
MetaModel.Default.VisibleTables;
if (visibleTables.Count == 0)
{
throw new InvalidOperationException(
"There are no accessible tables. Make sure that at least one data model is registered in Global.asax and scaffolding is enabled or implement custom pages.");
}
Menu1.DataSource = visibleTables;
Menu1.DataBind();
}
}
Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports System.Web.DynamicData
Imports System.Text
Partial Public Class _TablesMenu
Inherits System.Web.UI.Page
'Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
' GetVisibleTables()
' GetTables()
'End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
'Dim visibleTables As System.Collections.IList = MetaModel.Default.VisibleTables
'If (visibleTables.Count = 0) Then
' Throw New InvalidOperationException("There are no accessible tables. Make sure that at least one data model is registered in Global.asax a" & _
' "nd scaffolding is enabled or implement custom pages.")
'End If
'Menu1.DataSource = visibleTables
'Menu1.DataBind()
GetVisibleTables()
GetTables()
End Sub
' Gets all the tables in the data model.
Protected Sub GetTables()
Dim tables As System.Collections.IList = MetaModel.[Default].Tables
If tables.Count = 0 Then
Throw New InvalidOperationException("There are no tables in the data model.")
End If
Menu2.DataSource = tables
Menu2.DataBind()
End Sub
' Gets only the visible tables in the data model.
Protected Sub GetVisibleTables()
Dim visibleTables As System.Collections.IList = MetaModel.[Default].VisibleTables
If visibleTables.Count = 0 Then
Throw New InvalidOperationException("There are no accessible tables. Make sure that at least one data model is registered in Global.asax and scaffolding is enabled or implement custom pages.")
End If
Menu1.DataSource = visibleTables
Menu1.DataBind()
End Sub
End Class
설명
컬렉션에는 표시되지 않는 테이블(동적 데이터 스캐폴딩의 일부가 아님)이 포함된 데이터 모델의 모든 테이블이 포함됩니다.
이 기능의 온라인 예제를 실행합니다.