本文整理汇总了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);
}
}