本文整理汇总了C#中System.Web.DynamicData.MetaModel.GetTable方法的典型用法代码示例。如果您正苦于以下问题:C# MetaModel.GetTable方法的具体用法?C# MetaModel.GetTable怎么用?C# MetaModel.GetTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.DynamicData.MetaModel
的用法示例。
在下文中一共展示了MetaModel.GetTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
//引入命名空间
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 DocGetTable : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
// Use GetTable methods.
public string GetAdresses(int index)
{
// Get the default data model.
MetaModel model = MetaModel.Default;
MetaTable mTable;
switch (index)
{
case 0:
// Get the metatable for the table with the
// specified entity type.
mTable = model.GetTable(typeof(CustomerAddress));
break;
case 1:
// Get the metatable for the table with the
// specified table name.
mTable = model.GetTable("CustomerAddresses");
break;
case 2:
// Get the metatable for the table with the
// specified table name and the specified data
// context.
mTable = model.GetTable("CustomerAddresses", typeof(AdventureWorksLTDataContext));
break;
default:
mTable = model.GetTable(typeof(CustomerAddress));
break;
}
// The following code dislays the actual value
// (adress) associated with a customer and link
// to the related Addresses table.
MetaForeignKeyColumn fkColumn =
(MetaForeignKeyColumn)mTable.GetColumn("Address");
Customer row = (Customer)GetDataItem();
StringBuilder addressList = new StringBuilder();
foreach (CustomerAddress childRow in row.CustomerAddresses)
{
addressList.Append(childRow.AddressType);
addressList.Append(":<br/>");
addressList.Append("<a href='");
addressList.Append(fkColumn.GetForeignKeyDetailsPath(childRow.Address));
addressList.Append("'>");
addressList.Append(childRow.Address.AddressLine1);
addressList.Append("</a><br/><br/>");
}
return addressList.ToString();
}
}
示例2: typeof
// Get the metatable for the table with the
// specified table name and the specified data
// context.
mTable = model.GetTable("CustomerAddresses", typeof(AdventureWorksLTDataContext));
示例3:
// Get the metatable for the table with the
// specified entity type.
mTable = model.GetTable(typeof(CustomerAddress));
示例4:
// Get the metatable for the table with the
// specified table name.
mTable = model.GetTable("CustomerAddresses");