本文整理汇总了C#中MetadataWorkspace.TryGetItem方法的典型用法代码示例。如果您正苦于以下问题:C# MetadataWorkspace.TryGetItem方法的具体用法?C# MetadataWorkspace.TryGetItem怎么用?C# MetadataWorkspace.TryGetItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetadataWorkspace
的用法示例。
在下文中一共展示了MetadataWorkspace.TryGetItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SerializedAddGeneratedViews
//Collect the names of the entitysetbases and the generated views from
//the generated type into a string so that we can produce a hash over it.
private void SerializedAddGeneratedViews(
MetadataWorkspace workspace, EntityViewContainer viewContainer, Dictionary<EntitySetBase, GeneratedView> extentMappingViews)
{
foreach (var extentView in viewContainer.ExtentViews)
{
EntityContainer entityContainer = null;
EntitySetBase extent = null;
var extentFullName = extentView.Key;
var extentNameIndex = extentFullName.LastIndexOf('.');
if (extentNameIndex != -1)
{
var entityContainerName = extentFullName.Substring(0, extentNameIndex);
var extentName = extentFullName.Substring(extentFullName.LastIndexOf('.') + 1);
if (!workspace.TryGetItem(entityContainerName, DataSpace.CSpace, out entityContainer))
{
workspace.TryGetItem(entityContainerName, DataSpace.SSpace, out entityContainer);
}
if (entityContainer != null)
{
entityContainer.BaseEntitySets.TryGetValue(extentName, false, out extent);
}
}
if (extent == null)
{
throw new MappingException(System.Data.Entity.Resources.Strings.Generated_Views_Invalid_Extent(extentFullName));
}
//Create a Generated view and cache it
GeneratedView generatedView;
//Add the view to the local dictionary
if (!extentMappingViews.TryGetValue(extent, out generatedView))
{
generatedView = GeneratedView.CreateGeneratedView(
extent,
null, // edmType
null, // commandTree
extentView.Value, // eSQL
m_storageMappingItemCollection,
new ConfigViewGenerator());
extentMappingViews.Add(extent, generatedView);
}
}
}
示例2: GetCSpacetype
public static EntityType GetCSpacetype(Type currentType, MetadataWorkspace mdw)
{
mdw.LoadFromAssembly(currentType.Assembly);
EntityType ospaceEntityType = null;
StructuralType cspaceEntityType = null;
if (mdw.TryGetItem<EntityType>(
currentType.FullName, DataSpace.OSpace, out ospaceEntityType))
{
if (mdw.TryGetEdmSpaceType(ospaceEntityType,
out cspaceEntityType))
return cspaceEntityType as EntityType;
}
return null;
}