本文整理汇总了C#中System.Data.Entity.Core.Metadata.Edm.EdmItemCollection.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# EdmItemCollection.OfType方法的具体用法?C# EdmItemCollection.OfType怎么用?C# EdmItemCollection.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Entity.Core.Metadata.Edm.EdmItemCollection
的用法示例。
在下文中一共展示了EdmItemCollection.OfType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadTypes
public void LoadTypes(EdmItemCollection edmItemCollection, ObjectItemCollection objectItemCollection)
{
DebugCheck.NotNull(edmItemCollection);
DebugCheck.NotNull(objectItemCollection);
foreach (var cSpaceType in edmItemCollection.OfType<EdmType>().Where(
t => t.BuiltInTypeKind == BuiltInTypeKind.EntityType
|| t.BuiltInTypeKind == BuiltInTypeKind.EnumType
|| t.BuiltInTypeKind == BuiltInTypeKind.ComplexType))
{
var clrType = cSpaceType.GetClrType();
if (clrType != null)
{
var oSpaceType = _typeFactory.TryCreateType(clrType, cSpaceType);
if (oSpaceType != null)
{
Debug.Assert(!_typeFactory.CspaceToOspace.ContainsKey(cSpaceType));
_typeFactory.CspaceToOspace.Add(cSpaceType, oSpaceType);
}
}
else
{
Debug.Assert(!(cSpaceType is EntityType || cSpaceType is ComplexType || cSpaceType is EnumType));
}
}
_typeFactory.CreateRelationships(edmItemCollection);
foreach (var resolve in _typeFactory.ReferenceResolutions)
{
resolve();
}
foreach (var edmType in _typeFactory.LoadedTypes.Values)
{
edmType.SetReadOnly();
}
objectItemCollection.AddLoadedTypes(_typeFactory.LoadedTypes);
objectItemCollection.OSpaceTypesLoaded = true;
}
示例2: Structural_annotations_are_read_into_metadata_properties
[Fact] // CodePlex 1832
public void Structural_annotations_are_read_into_metadata_properties()
{
var edmItemCollection = new EdmItemCollection(new[] { XDocument.Parse(CsdlWithStructs).CreateReader() });
var entityType = edmItemCollection.OfType<EntityType>().Single(e => e.Name == "NorwegianAnimal");
var entityAnnotation = entityType.MetadataProperties.Single(p => p.Name == "FoxAnnotations:TheSecretOfTheFox");
var element = ((XElement)entityAnnotation.Value);
Assert.Equal("FoxAnnotations", element.Name.Namespace);
Assert.Equal("TheSecretOfTheFox", element.Name.LocalName);
var innerElement = element.Elements().Single();
Assert.Equal("", innerElement.Name.Namespace);
Assert.Equal("Secret", innerElement.Name.LocalName);
Assert.Equal("Ancient Mystery", innerElement.Attributes().Single(e => e.Name.LocalName == "Name").Value);
var property = entityType.Properties.Single(p => p.Name == "WhatDoesItSay");
var propertyAnnotation = property.MetadataProperties.Single(p => p.Name == "FoxAnnotations:TheSecretOfTheFox");
element = ((XElement)propertyAnnotation.Value);
Assert.Equal("FoxAnnotations", element.Name.Namespace);
Assert.Equal("TheSecretOfTheFox", element.Name.LocalName);
Assert.Equal(2, element.Elements().Count());
Assert.True(element.Elements().All(e => e.Name.Namespace == "FoxAnnotations"));
Assert.True(element.Elements().All(e => e.Name.LocalName == "Option"));
Assert.Equal(
new[] { "Hattie Hattie Hattie Ho", "Wa-pa-pa-pa-pa-pow!" },
element.Elements().Attributes().Where(e => e.Name.LocalName == "Name").Select(a => a.Value));
}