本文整理汇总了C#中Microsoft.OData.Edm.Library.EdmComplexTypeReference.AsEntity方法的典型用法代码示例。如果您正苦于以下问题:C# EdmComplexTypeReference.AsEntity方法的具体用法?C# EdmComplexTypeReference.AsEntity怎么用?C# EdmComplexTypeReference.AsEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.OData.Edm.Library.EdmComplexTypeReference
的用法示例。
在下文中一共展示了EdmComplexTypeReference.AsEntity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExerciseBadtypes
public void ExerciseBadtypes()
{
IEdmModel model = new EdmModel();
IEdmEntityType entityDef = new EdmEntityType("MyNamespace", "BadEntity");
IEdmEntityTypeReference entityRef = new EdmEntityTypeReference(entityDef, false);
IEdmComplexType complexDef = new EdmComplexType("MyNamespace", "BadComplex");
IEdmComplexTypeReference complexRef = new EdmComplexTypeReference(complexDef, false);
IEdmCollectionTypeReference badCollectionRef = entityRef.AsCollection();
IEdmEntityTypeReference badEntityRef = complexRef.AsEntity();
IEdmComplexTypeReference badComplexRef = entityRef.AsComplex();
IEdmEntityReferenceTypeReference badEntityRefRef = entityRef.AsEntityReference();
IEdmPrimitiveTypeReference badTemporal = entityRef.AsTemporal();
IEdmPrimitiveTypeReference badDecimal = entityRef.AsDecimal();
IEdmPrimitiveTypeReference badString = entityRef.AsString();
IEdmPrimitiveTypeReference badSpatial = entityRef.AsSpatial();
IEdmPrimitiveTypeReference badBinary = entityRef.AsBinary();
IEdmPrimitiveTypeReference badPrimitive = entityRef.AsPrimitive();
IEdmEnumTypeReference badEnum = entityRef.AsEnum();
Assert.IsTrue(badCollectionRef.IsCollection(), "Bad collection is collection");
Assert.IsTrue(badEntityRef.IsEntity(), "Bad Entity is Entity");
Assert.AreEqual(0, badEntityRef.Key().Count(), "Bad Entity has no key");
Assert.AreEqual("MyNamespace.BadComplex", badEntityRef.FullName(), "Bad named refs keep name");
Assert.AreEqual(EdmSchemaElementKind.TypeDefinition, badEntityRef.EntityDefinition().SchemaElementKind, "Bad named type definitions are still type definitions");
Assert.IsNull(badEntityRef.EntityDefinition().BaseType, "Bad Entity has no base type");
Assert.AreEqual(Enumerable.Empty<IEdmProperty>(), badEntityRef.EntityDefinition().DeclaredProperties, "Bad structured types have no properties");
Assert.IsFalse(badEntityRef.EntityDefinition().IsAbstract, "Bad structured types are not abstract");
Assert.IsFalse(badEntityRef.EntityDefinition().IsOpen, "Bad structured types are not open");
model.SetAnnotationValue(badEntityRef.Definition, "foo", "bar", new EdmStringConstant(new EdmStringTypeReference(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.String), false), "baz"));
Assert.AreEqual(1, model.DirectValueAnnotations(badEntityRef.Definition).Count(), "Bad Entity can hold annotations");
Assert.IsNotNull(model.GetAnnotationValue(badEntityRef.Definition, "foo", "bar"), "Bad Entity can find annotations");
Assert.AreEqual(EdmTermKind.Type, badEntityRef.EntityDefinition().TermKind, "EntityType has correct term kind");
Assert.IsTrue(badComplexRef.IsComplex(), "Bad Complex is Bad");
Assert.IsNull(badComplexRef.ComplexDefinition().FindProperty("PropertyName"), "Bad structured types return null for find property");
Assert.AreEqual(EdmTypeKind.EntityReference, badEntityRefRef.TypeKind(), "Bad Entity Reference is Entity Reference");
Assert.AreEqual(String.Empty, badEntityRefRef.EntityType().Name, "Bad Entity Reference has empty named EntityType");
model.SetAnnotationValue(badEntityRefRef.Definition, "foo", "bar", new EdmStringConstant(new EdmStringTypeReference(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.String), false), "baz"));
Assert.AreEqual(1, model.DirectValueAnnotations(badEntityRefRef.Definition).Count(), "Bad Entity Reference can hold annotations");
Assert.IsNotNull(model.GetAnnotationValue(badEntityRefRef.Definition, "foo", "bar"), "Bad Entity Reference can find annotations");
Assert.AreEqual(EdmPrimitiveTypeKind.None, badPrimitive.PrimitiveKind(), "Bad Primitive has no primitive kind");
Assert.AreEqual(EdmTypeKind.Primitive, badPrimitive.TypeKind(), "Bad Primitive has primitive type kind");
Assert.AreEqual(EdmSchemaElementKind.TypeDefinition, badPrimitive.PrimitiveDefinition().SchemaElementKind, "Bad Primitive is still Type Definition");
Assert.AreEqual("BadEntity", badPrimitive.PrimitiveDefinition().Name, "Bad Primitive retains name");
Assert.AreEqual("MyNamespace", badPrimitive.PrimitiveDefinition().Namespace, "Bad Primitive retains namespace name");
Assert.AreEqual(EdmTypeKind.Enum, badEnum.TypeKind(), "Bad enum has right kind.");
Assert.AreEqual(EdmPrimitiveTypeKind.Int32, badEnum.EnumDefinition().UnderlyingType.PrimitiveKind, "Underlying type has correct kind.");
Assert.AreEqual(0, badEnum.EnumDefinition().Members.Count(), "bad enum has no members.");
Assert.AreEqual(false, badEnum.EnumDefinition().IsFlags, "bad enum not treated as bits.");
Assert.AreEqual(EdmSchemaElementKind.TypeDefinition, badEnum.EnumDefinition().SchemaElementKind, "bad enum is type definition.");
Assert.AreEqual("BadEntity", badEnum.EnumDefinition().Name, "Bad enum retains name");
Assert.AreEqual("MyNamespace", badEnum.EnumDefinition().Namespace, "Bad enum retains namespace name");
Assert.AreEqual(EdmErrorCode.TypeSemanticsCouldNotConvertTypeReference, badSpatial.Definition.Errors().First().ErrorCode, "Bad spatial has correct error code.");
}