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


C# MetaModel.GetTable方法代码示例

本文整理汇总了C#中MetaModel.GetTable方法的典型用法代码示例。如果您正苦于以下问题:C# MetaModel.GetTable方法的具体用法?C# MetaModel.GetTable怎么用?C# MetaModel.GetTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MetaModel的用法示例。


在下文中一共展示了MetaModel.GetTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetDataObject

        public void SetDataObject(object dataObject, DetailsView detailsView) {

            DataObject = dataObject;
            TypeDescriptionProvider typeDescriptionProvider;

            CustomTypeDescriptor = dataObject as ICustomTypeDescriptor;
            Type dataObjectType;

            if (CustomTypeDescriptor == null) {
                dataObjectType = dataObject.GetType();
                typeDescriptionProvider = TypeDescriptor.GetProvider(DataObject);
                CustomTypeDescriptor = typeDescriptionProvider.GetTypeDescriptor(DataObject);
            }
            else {
                dataObjectType = GetEntityType();
                typeDescriptionProvider = new TrivialTypeDescriptionProvider(CustomTypeDescriptor);
            }

            // Set the context type and entity set name on ourselves. Note that in this scenario those
            // concepts are somewhat artificial, since we don't have a real context. 

            // Set the ContextType to the dataObjectType, which is a bit strange but harmless
            Type contextType = dataObjectType;

            ((IDynamicDataSource)this).ContextType = contextType;

            // We can set the entity set name to anything, but using the
            // DataObjectType makes some Dynamic Data error messages clearer.
            ((IDynamicDataSource)this).EntitySetName = dataObjectType.Name;

            MetaModel model = null;
            try {
                model = MetaModel.GetModel(contextType);
            }
            catch {
                model = new MetaModel();
                model.RegisterContext(
                    new SimpleModelProvider(contextType, dataObjectType, dataObject),
                    new ContextConfiguration() {
                        MetadataProviderFactory = (type => typeDescriptionProvider)
                    });
            }

            MetaTable table = model.GetTable(dataObjectType);

            if (detailsView != null) {
                detailsView.RowsGenerator = new AdvancedFieldGenerator(table, false);
            }
        }
开发者ID:sanyaade-mobiledev,项目名称:ASP.NET-Mvc-2,代码行数:49,代码来源:SimpleDynamicDataSource.cs


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