当前位置: 首页>>代码示例>>C#>>正文


C# MetaModel.GetTable方法代码示例

本文整理汇总了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();
    }
}
开发者ID:.NET开发者,项目名称:System.Web.DynamicData,代码行数:77,代码来源:MetaModel.GetTable

示例2: typeof

// Get the metatable for the table with the 
// specified table name and the specified data
// context.
mTable = model.GetTable("CustomerAddresses", typeof(AdventureWorksLTDataContext));
开发者ID:.NET开发者,项目名称:System.Web.DynamicData,代码行数:4,代码来源:MetaModel.GetTable

示例3:

// Get the metatable for the table with the
// specified entity type.
mTable = model.GetTable(typeof(CustomerAddress));
开发者ID:.NET开发者,项目名称:System.Web.DynamicData,代码行数:3,代码来源:MetaModel.GetTable

示例4:

// Get the metatable for the table with the 
// specified table name.
mTable = model.GetTable("CustomerAddresses");
开发者ID:.NET开发者,项目名称:System.Web.DynamicData,代码行数:3,代码来源:MetaModel.GetTable


注:本文中的System.Web.DynamicData.MetaModel.GetTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。