本文整理汇总了C#中Microsoft.OData.Edm.Library.EdmComplexTypeReference类的典型用法代码示例。如果您正苦于以下问题:C# EdmComplexTypeReference类的具体用法?C# EdmComplexTypeReference怎么用?C# EdmComplexTypeReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmComplexTypeReference类属于Microsoft.OData.Edm.Library命名空间,在下文中一共展示了EdmComplexTypeReference类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Initialize
public void Initialize()
{
var addressEdmType = new EdmComplexType("Default", "Address");
addressEdmType.AddStructuralProperty("ZipCode", EdmPrimitiveTypeKind.String);
this.edmAddressComplexTypeRef = new EdmComplexTypeReference(addressEdmType, true);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:7,代码来源:MaterializationPolicyUnitTests.cs
示例2: NonPrimitiveIsXXXMethods
public void NonPrimitiveIsXXXMethods()
{
IEdmEntityType entityDef = new EdmEntityType("MyNamespace", "MyEntity");
IEdmEntityTypeReference entityRef = new EdmEntityTypeReference(entityDef, false);
Assert.IsTrue(entityRef.IsEntity(), "Entity is Entity");
IEdmPrimitiveTypeReference bad = entityRef.AsPrimitive();
Assert.IsTrue(bad.Definition.IsBad(), "bad TypeReference is bad");
Assert.AreEqual(EdmErrorCode.TypeSemanticsCouldNotConvertTypeReference, bad.Definition.Errors().First().ErrorCode, "Reference is bad from conversion");
Assert.IsTrue(bad.Definition.IsBad(), "Bad definition is bad");
Assert.AreEqual(EdmErrorCode.TypeSemanticsCouldNotConvertTypeReference, bad.Definition.Errors().First().ErrorCode, "Definition is bad from conversion");
IEdmPrimitiveType intDef = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Int32);
IEdmPrimitiveTypeReference intRef = new EdmPrimitiveTypeReference(intDef, false);
IEdmCollectionTypeReference intCollection = new EdmCollectionTypeReference(new EdmCollectionType(intRef));
Assert.IsTrue(intCollection.IsCollection(), "Collection is collection");
IEdmComplexType complexDef = new EdmComplexType("MyNamespace", "MyComplex");
IEdmComplexTypeReference complexRef = new EdmComplexTypeReference(complexDef, false);
Assert.IsTrue(complexRef.IsComplex(), "Complex is Complex");
Assert.IsTrue(entityRef.IsStructured(), "Entity is Structured");
Assert.IsTrue(complexRef.IsStructured(), "Complex is stuctured");
Assert.IsFalse(intCollection.IsStructured(), "Collection is not structured");
}
开发者ID:AlineGuan,项目名称:odata.net,代码行数:26,代码来源:TypeSemanticsUnitTests.cs
示例3: Init
public void Init()
{
EdmModel model = new EdmModel();
EdmComplexType complex1 = new EdmComplexType("ns", "complex1");
complex1.AddProperty(new EdmStructuralProperty(complex1, "p1", EdmCoreModel.Instance.GetInt32(isNullable: false)));
model.AddElement(complex1);
EdmComplexType complex2 = new EdmComplexType("ns", "complex2");
complex2.AddProperty(new EdmStructuralProperty(complex2, "p1", EdmCoreModel.Instance.GetInt32(isNullable: false)));
model.AddElement(complex2);
EdmComplexTypeReference complex2Reference = new EdmComplexTypeReference(complex2, isNullable: false);
EdmCollectionType primitiveCollectionType = new EdmCollectionType(EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Int32, isNullable: false));
EdmCollectionType complexCollectionType = new EdmCollectionType(complex2Reference);
EdmCollectionTypeReference primitiveCollectionTypeReference = new EdmCollectionTypeReference(primitiveCollectionType);
EdmCollectionTypeReference complexCollectionTypeReference = new EdmCollectionTypeReference(complexCollectionType);
model.AddElement(new EdmTerm("custom", "int", EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Int32, isNullable: false)));
model.AddElement(new EdmTerm("custom", "string", EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.String, isNullable: false)));
model.AddElement(new EdmTerm("custom", "double", EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Double, isNullable: false)));
model.AddElement(new EdmTerm("custom", "bool", EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Boolean, isNullable: true)));
model.AddElement(new EdmTerm("custom", "decimal", EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Decimal, isNullable: false)));
model.AddElement(new EdmTerm("custom", "timespan", EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Duration, isNullable: false)));
model.AddElement(new EdmTerm("custom", "guid", EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Guid, isNullable: false)));
model.AddElement(new EdmTerm("custom", "complex", complex2Reference));
model.AddElement(new EdmTerm("custom", "primitiveCollection", primitiveCollectionTypeReference));
model.AddElement(new EdmTerm("custom", "complexCollection", complexCollectionTypeReference));
this.stream = new MemoryStream();
this.settings = new ODataMessageWriterSettings { Version = ODataVersion.V4, ShouldIncludeAnnotation = ODataUtils.CreateAnnotationFilter("*") };
this.settings.SetServiceDocumentUri(ServiceDocumentUri);
this.serializer = new ODataAtomPropertyAndValueSerializer(this.CreateAtomOutputContext(model, this.stream));
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:34,代码来源:ODataAtomPropertyAndValueSerializerTests.cs
示例4: ODataJsonLightInheritComplexCollectionWriterTests
public ODataJsonLightInheritComplexCollectionWriterTests()
{
collectionStartWithoutSerializationInfo = new ODataCollectionStart();
collectionStartWithSerializationInfo = new ODataCollectionStart();
collectionStartWithSerializationInfo.SetSerializationInfo(new ODataCollectionStartSerializationInfo { CollectionTypeName = "Collection(ns.Address)" });
address = new ODataComplexValue { Properties = new[]
{
new ODataProperty { Name = "Street", Value = "1 Microsoft Way" },
new ODataProperty { Name = "Zipcode", Value = 98052 },
new ODataProperty { Name = "State", Value = new ODataEnumValue("WA", "ns.StateEnum") },
new ODataProperty { Name = "City", Value = "Shanghai" }
}, TypeName = "TestNamespace.DerivedAddress" };
items = new[] { address };
EdmComplexType addressType = new EdmComplexType("ns", "Address");
addressType.AddProperty(new EdmStructuralProperty(addressType, "Street", EdmCoreModel.Instance.GetString(isNullable: true)));
addressType.AddProperty(new EdmStructuralProperty(addressType, "Zipcode", EdmCoreModel.Instance.GetInt32(isNullable: true)));
var stateEnumType = new EdmEnumType("ns", "StateEnum", isFlags: true);
stateEnumType.AddMember("IL", new EdmIntegerConstant(1));
stateEnumType.AddMember("WA", new EdmIntegerConstant(2));
addressType.AddProperty(new EdmStructuralProperty(addressType, "State", new EdmEnumTypeReference(stateEnumType, true)));
EdmComplexType derivedAddressType = new EdmComplexType("ns", "DerivedAddress", addressType, false);
derivedAddressType.AddProperty(new EdmStructuralProperty(derivedAddressType, "City", EdmCoreModel.Instance.GetString(isNullable: true)));
addressTypeReference = new EdmComplexTypeReference(addressType, isNullable: false);
derivedAddressTypeReference = new EdmComplexTypeReference(derivedAddressType, isNullable: false);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:30,代码来源:ODataJsonLightInheritComplexCollectionWriterTests.cs
示例5: GetEdmType_Returns_EdmTypeInitializedByCtor
public void GetEdmType_Returns_EdmTypeInitializedByCtor()
{
IEdmTypeReference elementType = new EdmComplexTypeReference(new EdmComplexType("NS", "Complex"), isNullable: false);
IEdmCollectionTypeReference collectionType = new EdmCollectionTypeReference(new EdmCollectionType(elementType));
var edmObject = new EdmComplexObjectCollection(collectionType);
Assert.Same(collectionType, edmObject.GetEdmType());
}
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:8,代码来源:EdmComplexCollectionObjectTest.cs
示例6: TypeNameShouldBeWrittenForUndeclaredComplexProperty
public void TypeNameShouldBeWrittenForUndeclaredComplexProperty()
{
var typeFromValue = new EdmComplexTypeReference(new EdmComplexType("Test", "ComplexType"), false);
this.typeNameOracle.GetValueTypeNameForWriting(new ODataComplexValue {TypeName = "Test.ComplexType"},
null,
typeFromValue,
/* isOpenProperty*/ true).Should().Be("Test.ComplexType");
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:8,代码来源:ODataWriterTypeNameUtilsTests.cs
示例7: TypeNameShouldNotBeWrittenForDeclaredComplexProperty
public void TypeNameShouldNotBeWrittenForDeclaredComplexProperty()
{
var typeFromMetadata = new EdmComplexTypeReference(new EdmComplexType("Test", "ComplexType"), true);
var typeFromValue = new EdmComplexTypeReference(new EdmComplexType("Test", "ComplexType"), false);
this.typeNameOracle.GetValueTypeNameForWriting(new ODataComplexValue {TypeName = "Test.ComplexType"},
typeFromMetadata,
typeFromValue,
/* isOpenProperty*/ false).Should().BeNull();
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:9,代码来源:ODataWriterTypeNameUtilsTests.cs
示例8: TryGetValue_ThrowsInvalidOperation_EdmComplexObjectNullRef
public void TryGetValue_ThrowsInvalidOperation_EdmComplexObjectNullRef()
{
IEdmComplexTypeReference edmType = new EdmComplexTypeReference(new EdmComplexType("NS", "ComplexType"), isNullable: true);
NullEdmComplexObject nullComplexObject = new NullEdmComplexObject(edmType);
object propertyValue;
Assert.Throws<InvalidOperationException>(() => nullComplexObject.TryGetPropertyValue("property", out propertyValue),
"Cannot get property 'property' of a null EDM object of type '[NS.ComplexType Nullable=True]'.");
}
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:9,代码来源:NullEdmComplexObjectTest.cs
示例9: GetEdmType_Returns_CtorInitializedValue
public void GetEdmType_Returns_CtorInitializedValue()
{
IEdmComplexTypeReference edmType = new EdmComplexTypeReference(new EdmComplexType("NS", "ComplexType"), isNullable: true);
NullEdmComplexObject nullComplexObject = new NullEdmComplexObject(edmType);
IEdmTypeReference result = nullComplexObject.GetEdmType();
Assert.Same(edmType, result);
}
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:9,代码来源:NullEdmComplexObjectTest.cs
示例10: EqualsOnComplexAndOtherComplexIsNotSupported
public void EqualsOnComplexAndOtherComplexIsNotSupported()
{
var otherComplexType = new EdmComplexTypeReference(new EdmComplexType("NS", "OtherComplex"), true);
IEdmTypeReference left = HardCodedTestModel.GetPersonAddressProp().Type;
IEdmTypeReference right = otherComplexType;
SingleValueNode leftNode = new SingleValuePropertyAccessNode(new ConstantNode(null)/*parent*/, new EdmStructuralProperty(new EdmEntityType("MyNamespace", "MyEntityType"), "myPropertyName", left));
SingleValueNode rightNode = new SingleValuePropertyAccessNode(new ConstantNode(null)/*parent*/, new EdmStructuralProperty(new EdmEntityType("MyNamespace", "MyEntityType"), "myPropertyName", right));
var result = TypePromotionUtils.PromoteOperandTypes(BinaryOperatorKind.Equal, leftNode, rightNode, out left, out right);
result.Should().BeFalse();
left.ShouldBeEquivalentTo(HardCodedTestModel.GetPersonAddressProp().Type);
right.ShouldBeEquivalentTo(otherComplexType);
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:13,代码来源:TypePromotionUtilsTests.cs
示例11: TestInitialize
public void TestInitialize()
{
this.MetadataDocumentUri = new Uri("http://www.myhost.com/myservice.svc/$metadata");
this.model = new EdmModel();
EdmEntityContainer defaultContainer = new EdmEntityContainer("TestModel", "DefaultContainer");
this.model.AddElement(defaultContainer);
this.cityType = new EdmEntityType("TestModel", "City");
EdmStructuralProperty cityIdProperty = cityType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(/*isNullable*/false));
cityType.AddKeys(cityIdProperty);
cityType.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(/*isNullable*/false));
cityType.AddStructuralProperty("Size", EdmCoreModel.Instance.GetInt32(/*isNullable*/false));
this.model.AddElement(cityType);
EdmComplexType complexType = new EdmComplexType("TestModel", "MyComplexType");
this.model.AddElement(complexType);
this.operationWithNoOverload = new EdmFunction("TestModel", "FunctionImportWithNoOverload", EdmCoreModel.Instance.GetInt32(true));
this.operationImportWithNoOverload = defaultContainer.AddFunctionImport("FunctionImportWithNoOverload", operationWithNoOverload);
this.model.AddElement(operationWithNoOverload);
this.operationWithOverloadAnd0Param = new EdmFunction("TestModel", "FunctionImportWithOverload", EdmCoreModel.Instance.GetInt32(true));
this.operationImportWithOverloadAnd0Param = defaultContainer.AddFunctionImport("FunctionImportWithOverload", operationWithOverloadAnd0Param);
this.operationWithOverloadAnd1Param = new EdmFunction("TestModel", "FunctionImportWithOverload", EdmCoreModel.Instance.GetInt32(true));
this.operationWithOverloadAnd1Param.AddParameter("p1", EdmCoreModel.Instance.GetInt32(false));
this.model.AddElement(operationWithOverloadAnd1Param);
this.operationImportWithOverloadAnd1Param = defaultContainer.AddFunctionImport("FunctionImportWithOverload", operationWithOverloadAnd1Param);
this.operationWithOverloadAnd2Params = new EdmFunction("TestModel", "FunctionImportWithOverload", EdmCoreModel.Instance.GetInt32(true));
var cityTypeReference = new EdmEntityTypeReference(this.cityType, isNullable: false);
this.operationWithOverloadAnd2Params.AddParameter("p1", cityTypeReference);
this.operationWithOverloadAnd2Params.AddParameter("p2", EdmCoreModel.Instance.GetString(true));
this.model.AddElement(operationWithOverloadAnd2Params);
this.operationImportWithOverloadAnd2Params = defaultContainer.AddFunctionImport("FunctionImportWithOverload", operationWithOverloadAnd2Params);
this.operationWithOverloadAnd5Params = new EdmFunction("TestModel", "FunctionImportWithOverload", EdmCoreModel.Instance.GetInt32(true));
this.operationWithOverloadAnd5Params.AddParameter("p1", new EdmCollectionTypeReference(new EdmCollectionType(cityTypeReference)));
this.operationWithOverloadAnd5Params.AddParameter("p2", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(isNullable: false))));
this.operationWithOverloadAnd5Params.AddParameter("p3", EdmCoreModel.Instance.GetString(isNullable: true));
EdmComplexTypeReference complexTypeReference = new EdmComplexTypeReference(complexType, isNullable: false);
this.operationWithOverloadAnd5Params.AddParameter("p4", complexTypeReference);
this.operationWithOverloadAnd5Params.AddParameter("p5", new EdmCollectionTypeReference(new EdmCollectionType(complexTypeReference)));
this.model.AddElement(operationWithOverloadAnd5Params);
this.operationImportWithOverloadAnd5Params = defaultContainer.AddFunctionImport("FunctionImportWithOverload", operationWithOverloadAnd5Params);
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:48,代码来源:ODataJsonLightUtilsTests.cs
示例12: ODataAtomAnnotationReaderTests
public ODataAtomAnnotationReaderTests()
{
this.model = new EdmModel();
this.model.AddElement(new EdmComplexType("foo", "complex"));
EdmComplexType complexType = new EdmComplexType("ns", "complex");
this.model.AddElement(complexType);
EdmComplexTypeReference complexTypeReference = new EdmComplexTypeReference(complexType, isNullable: false);
EdmCollectionType primitiveCollectionType = new EdmCollectionType(EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Guid, isNullable: false));
EdmCollectionType complexCollectionType = new EdmCollectionType(complexTypeReference);
EdmCollectionTypeReference primitiveCollectionTypeReference = new EdmCollectionTypeReference(primitiveCollectionType);
EdmCollectionTypeReference complexCollectionTypeReference = new EdmCollectionTypeReference(complexCollectionType);
this.model.AddElement(new EdmTerm("custom", "primitive", EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Double, isNullable: false)));
this.model.AddElement(new EdmTerm("custom", "complex", complexTypeReference));
this.model.AddElement(new EdmTerm("custom", "primitiveCollection", primitiveCollectionTypeReference));
this.model.AddElement(new EdmTerm("custom", "complexCollection", complexCollectionTypeReference));
this.shouldIncludeAnnotation = (annotationName) => true;
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:19,代码来源:ODataAtomAnnotationReaderTests.cs
示例13: EdmLibraryExtensionsTests
public EdmLibraryExtensionsTests()
{
this.model = TestModel.BuildDefaultTestModel();
this.defaultContainer = (EdmEntityContainer)this.model.FindEntityContainer("Default");
this.productsSet = this.defaultContainer.FindEntitySet("Products");
this.productType = (IEdmEntityType)this.model.FindDeclaredType("TestModel.Product");
this.productTypeReference = new EdmEntityTypeReference(this.productType, false);
EdmComplexType complexType = new EdmComplexType("TestModel", "MyComplexType");
this.operationWithNoOverload = new EdmFunction("TestModel", "FunctionImportWithNoOverload", EdmCoreModel.Instance.GetInt32(true));
this.operationWithNoOverload.AddParameter("p1", EdmCoreModel.Instance.GetInt32(false));
this.model.AddElement(operationWithNoOverload);
this.operationImportWithNoOverload = this.defaultContainer.AddFunctionImport("FunctionImportWithNoOverload", operationWithNoOverload);
this.operationWithOverloadAnd0Param = new EdmFunction("TestModel", "FunctionImportWithNoOverload", EdmCoreModel.Instance.GetInt32(true));
this.model.AddElement(operationWithOverloadAnd0Param);
this.operationImportWithOverloadAnd0Param = defaultContainer.AddFunctionImport("FunctionImportWithOverload", operationWithOverloadAnd0Param);
this.operationWithOverloadAnd1Param = new EdmFunction("TestModel", "FunctionImportWithNoOverload", EdmCoreModel.Instance.GetInt32(true));
this.operationWithOverloadAnd1Param.AddParameter("p1", EdmCoreModel.Instance.GetInt32(false));
this.model.AddElement(operationWithOverloadAnd1Param);
this.operationImportWithOverloadAnd1Param = defaultContainer.AddFunctionImport("FunctionImportWithOverload", operationWithOverloadAnd1Param);
this.operationWithOverloadAnd2Params = new EdmFunction("TestModel", "FunctionImportWithNoOverload", EdmCoreModel.Instance.GetInt32(true));
var productTypeReference = new EdmEntityTypeReference(productType, isNullable: false);
this.operationWithOverloadAnd2Params.AddParameter("p1", productTypeReference);
this.operationWithOverloadAnd2Params.AddParameter("p2", EdmCoreModel.Instance.GetString(true));
this.model.AddElement(operationWithOverloadAnd2Params);
this.operationImportWithOverloadAnd2Params = defaultContainer.AddFunctionImport("FunctionImportWithOverload", operationWithOverloadAnd2Params);
this.operationWithOverloadAnd5Params = new EdmFunction("TestModel", "FunctionImportWithNoOverload", EdmCoreModel.Instance.GetInt32(true));
this.operationWithOverloadAnd5Params.AddParameter("p1", new EdmCollectionTypeReference(new EdmCollectionType(productTypeReference)));
this.operationWithOverloadAnd5Params.AddParameter("p2", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(isNullable: false))));
this.operationWithOverloadAnd5Params.AddParameter("p3", EdmCoreModel.Instance.GetString(isNullable: true));
EdmComplexTypeReference complexTypeReference = new EdmComplexTypeReference(complexType, isNullable: false);
this.operationWithOverloadAnd5Params.AddParameter("p4", complexTypeReference);
this.operationWithOverloadAnd5Params.AddParameter("p5", new EdmCollectionTypeReference(new EdmCollectionType(complexTypeReference)));
this.model.AddElement(operationWithOverloadAnd5Params);
this.operationImportWithOverloadAnd5Params = defaultContainer.AddFunctionImport("FunctionImportWithOverload", operationWithOverloadAnd5Params);
}
开发者ID:rossjempson,项目名称:odata.net,代码行数:41,代码来源:EdmLibraryExtensionsTests.cs
示例14: TaupoDefaultModelEdm
public static IEdmModel TaupoDefaultModelEdm()
{
var model = new EdmModel();
#region TaupoDefault Model code
var phoneType = new EdmComplexType("NS1", "Phone");
phoneType.AddStructuralProperty("PhoneNumber", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 16, isUnicode: false, isNullable: false));
phoneType.AddStructuralProperty("Extension", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 16, isUnicode: false, isNullable: true));
model.AddElement(phoneType);
var phoneTypeReference = new EdmComplexTypeReference(phoneType, false);
var contactDetailsType = new EdmComplexType("NS1", "ContactDetails");
contactDetailsType.AddStructuralProperty("Email", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 32, isUnicode: false, isNullable: false));
contactDetailsType.AddStructuralProperty("HomePhone", phoneTypeReference);
contactDetailsType.AddStructuralProperty("WorkPhone", phoneTypeReference);
contactDetailsType.AddStructuralProperty("MobilePhone", phoneTypeReference);
model.AddElement(contactDetailsType);
var contactDetailsTypeReference = new EdmComplexTypeReference(contactDetailsType, false);
var concurrencyInfoType = new EdmComplexType("NS1", "ConcurrencyInfo");
concurrencyInfoType.AddStructuralProperty("Token", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 20, isUnicode: false, isNullable: false), string.Empty, EdmConcurrencyMode.Fixed);
concurrencyInfoType.AddStructuralProperty("QueriedDateTimeOffset", EdmCoreModel.Instance.GetDateTimeOffset(true));
model.AddElement(concurrencyInfoType);
var concurrencyInfoTypeReference = new EdmComplexTypeReference(concurrencyInfoType, false);
var auditInfoType = new EdmComplexType("NS1", "AuditInfo");
auditInfoType.AddStructuralProperty("ModifiedDate", EdmPrimitiveTypeKind.DateTimeOffset);
auditInfoType.AddStructuralProperty("ModifiedBy", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 50, isUnicode: false, isNullable: false));
auditInfoType.AddStructuralProperty("Concurrency", new EdmComplexTypeReference(concurrencyInfoType, false));
model.AddElement(auditInfoType);
var auditInfoTypeReference = new EdmComplexTypeReference(auditInfoType, false);
var dimensionsType = new EdmComplexType("NS1", "Dimensions");
dimensionsType.AddStructuralProperty("Width", EdmCoreModel.Instance.GetDecimal(10, 3, false));
dimensionsType.AddStructuralProperty("Height", EdmCoreModel.Instance.GetDecimal(10, 3, false));
dimensionsType.AddStructuralProperty("Depth", EdmCoreModel.Instance.GetDecimal(10, 3, false));
model.AddElement(dimensionsType);
var dimensionsTypeReference = new EdmComplexTypeReference(dimensionsType, false);
var suspiciousActivityType = new EdmEntityType("NS1", "SuspiciousActivity");
suspiciousActivityType.AddKeys(suspiciousActivityType.AddStructuralProperty("SuspiciousActivityId", EdmPrimitiveTypeKind.Int32, false));
suspiciousActivityType.AddStructuralProperty("Activity", EdmPrimitiveTypeKind.String);
model.AddElement(suspiciousActivityType);
var messageType = new EdmEntityType("NS1", "Message");
var fromUsername = messageType.AddStructuralProperty("FromUsername", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 50, isUnicode: false));
messageType.AddKeys(messageType.AddStructuralProperty("MessageId", EdmPrimitiveTypeKind.Int32, false), fromUsername);
var toUsername = messageType.AddStructuralProperty("ToUsername", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 50, isUnicode: false));
messageType.AddStructuralProperty("Sent", EdmPrimitiveTypeKind.DateTimeOffset);
messageType.AddStructuralProperty("Subject", EdmPrimitiveTypeKind.String);
messageType.AddStructuralProperty("Body", EdmCoreModel.Instance.GetString(true));
messageType.AddStructuralProperty("IsRead", EdmCoreModel.Instance.GetBoolean(false));
model.AddElement(messageType);
var loginType = new EdmEntityType("NS1", "Login");
loginType.AddKeys(loginType.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 50, isUnicode: false)));
var loginCustomerIdProperty = loginType.AddStructuralProperty("CustomerId", EdmPrimitiveTypeKind.Int32, false);
model.AddElement(loginType);
var loginSentMessages = new EdmNavigationPropertyInfo { Name = "SentMessages", Target = messageType, TargetMultiplicity = EdmMultiplicity.Many };
var messageSender = new EdmNavigationPropertyInfo { Name = "Sender", Target = loginType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { fromUsername }, PrincipalProperties = loginType.Key() };
loginType.AddBidirectionalNavigation(loginSentMessages, messageSender);
var loginReceivedMessages = new EdmNavigationPropertyInfo { Name = "ReceivedMessages", Target = messageType, TargetMultiplicity = EdmMultiplicity.Many };
var messageRecipient = new EdmNavigationPropertyInfo { Name = "Recipient", Target = loginType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { fromUsername }, PrincipalProperties = loginType.Key() };
loginType.AddBidirectionalNavigation(loginReceivedMessages, messageRecipient);
var loginSuspiciousActivity = new EdmNavigationPropertyInfo { Name = "SuspiciousActivity", Target = suspiciousActivityType, TargetMultiplicity = EdmMultiplicity.Many };
loginType.AddUnidirectionalNavigation(loginSuspiciousActivity);
var lastLoginType = new EdmEntityType("NS1", "LastLogin");
var userNameProperty = lastLoginType.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 50, isUnicode: false));
lastLoginType.AddKeys(userNameProperty);
lastLoginType.AddStructuralProperty("LoggedIn", EdmPrimitiveTypeKind.DateTimeOffset);
lastLoginType.AddStructuralProperty("LoggedOut", EdmCoreModel.Instance.GetDateTimeOffset(true));
model.AddElement(lastLoginType);
var loginLastLogin = new EdmNavigationPropertyInfo { Name = "LastLogin", Target = lastLoginType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne };
var lastLoginLogin = new EdmNavigationPropertyInfo { Name = "Login", Target = loginType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { userNameProperty }, PrincipalProperties = loginType.Key() };
lastLoginType.AddBidirectionalNavigation(lastLoginLogin, loginLastLogin);
var orderType = new EdmEntityType("NS1", "Order");
orderType.AddKeys(orderType.AddStructuralProperty("OrderId", EdmPrimitiveTypeKind.Int32, false));
var orderCustomerId = orderType.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(true));
orderType.AddStructuralProperty("Concurrency", concurrencyInfoTypeReference);
model.AddElement(orderType);
var loginOrders = new EdmNavigationPropertyInfo { Name = "Orders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many };
var orderLogin = new EdmNavigationPropertyInfo { Name = "Login", Target = loginType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne };
orderType.AddBidirectionalNavigation(orderLogin, loginOrders);
var customerInfoType = new EdmEntityType("NS1", "CustomerInfo");
customerInfoType.AddKeys(customerInfoType.AddStructuralProperty("CustomerInfoId", EdmPrimitiveTypeKind.Int32, false));
customerInfoType.AddStructuralProperty("Information", EdmPrimitiveTypeKind.String);
model.AddElement(customerInfoType);
var customerType = new EdmEntityType("NS1", "Customer");
var customerIdProperty = customerType.AddStructuralProperty("CustomerId", EdmPrimitiveTypeKind.Int32, false);
customerType.AddKeys(customerIdProperty);
customerType.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 100, isUnicode: false, isNullable: false));
customerType.AddStructuralProperty("ContactInfo", contactDetailsTypeReference);
model.AddElement(customerType);
//.........这里部分代码省略.........
开发者ID:larsenjo,项目名称:odata.net,代码行数:101,代码来源:ModelBuilder.cs
示例15: BuildTableValueType
IEdmTypeReference BuildTableValueType(string name, EdmModel model)
{
EdmEntityContainer container = model.EntityContainer as EdmEntityContainer;
string spRtvTypeName = string.Format("{0}_RtvCollectionType", name);
EdmComplexType t = null;
t = new EdmComplexType("ns", spRtvTypeName);
using (DbAccess db = new DbAccess(this.ConnectionString))
{
db.ExecuteReader(this.TableValuedResultSetCommand, (reader) =>
{
var et = Utility.DBType2EdmType(reader["DATA_TYPE"].ToString());
if (et.HasValue)
{
string col = reader["COLUMN_NAME"].ToString();
t.AddStructuralProperty(col, et.Value, true);
}
}, (par) => { par.AddWithValue("@Name", name); });
}
var etr = new EdmComplexTypeReference(t, true);
var t1 = new EdmCollectionTypeReference(new EdmCollectionType(etr));
model.AddElement((t1.Definition as EdmCollectionType).ElementType.Definition as IEdmSchemaElement);
return t1;
}
开发者ID:maskx,项目名称:OData,代码行数:24,代码来源:SQLDataSource.cs
示例16: BuildSPReturnType
IEdmTypeReference BuildSPReturnType(string spName, EdmModel model)
{
EdmEntityContainer container = model.EntityContainer as EdmEntityContainer;
string spRtvTypeName = string.Format("{0}_RtvCollectionType", spName);
EdmComplexType t = null;
t = new EdmComplexType("ns", spRtvTypeName);
using (DbAccess db = new DbAccess(this.ConnectionString))
{
db.ExecuteReader(StoredProcedureResultSetCommand, (reader) =>
{
if (reader.IsDBNull("DATA_TYPE"))
return;
var et = Utility.DBType2EdmType(reader["DATA_TYPE"].ToString());
if (et.HasValue)
{
string col = reader["COLUMN_NAME"].ToString();
if (string.IsNullOrEmpty(col))
throw new Exception(string.Format("{0} has wrong return type. see [exec GetEdmSPResultSet '{0}'] ", spName));
t.AddStructuralProperty(col, et.Value, true);
}
}, (par) => { par.AddWithValue("@Name", spName); });
}
var etr = new EdmComplexTypeReference(t, true);
return new EdmCollectionTypeReference(new EdmCollectionType(etr));
}
开发者ID:maskx,项目名称:OData,代码行数:26,代码来源:SQLDataSource.cs
示例17: ConvertComplexValue
private static object ConvertComplexValue(ODataComplexValue complexValue, ref IEdmTypeReference propertyType,
ODataDeserializerProvider deserializerProvider, ODataDeserializerContext readContext)
{
IEdmComplexTypeReference edmComplexType;
if (propertyType == null)
{
// open complex property
Contract.Assert(!String.IsNullOrEmpty(complexValue.TypeName),
"ODataLib should have verified that open complex value has a type name since we provided metadata.");
IEdmModel model = readContext.Model;
IEdmType edmType = model.FindType(complexValue.TypeName);
Contract.Assert(edmType.TypeKind == EdmTypeKind.Complex, "ODataLib should have verified that complex value has a complex resource type.");
edmComplexType = new EdmComplexTypeReference(edmType as IEdmComplexType, isNullable: true);
propertyType = edmComplexType;
}
else
{
edmComplexType = propertyType.AsComplex();
}
ODataEdmTypeDeserializer deserializer = deserializerProvider.GetEdmTypeDeserializer(edmComplexType);
return deserializer.ReadInline(complexValue, propertyType, readContext);
}
开发者ID:joshcomley,项目名称:WebApi,代码行数:23,代码来源:DeserializationHelpers.cs
示例18: WritingMultipleInstanceAnnotationInComplexValueShouldSkipBaseOnSettings
public void WritingMultipleInstanceAnnotationInComplexValueShouldSkipBaseOnSettings()
{
var complexType = new EdmComplexType("TestNamespace", "Address");
model.AddElement(complexType);
var result = this.SetupSerializerAndRunTest(serializer =>
{
var complexValue = new ODataComplexValue
{
TypeName = "TestNamespace.Address",
InstanceAnnotations = new Collection<ODataInstanceAnnotation>
{
new ODataInstanceAnnotation("Annotation.1", new ODataPrimitiveValue(true)),
new ODataInstanceAnnotation("Annotation.2", new ODataPrimitiveValue(123)),
new ODataInstanceAnnotation("Annotation.3", new ODataPrimitiveValue("annotation"))
}
};
var complexTypeRef = new EdmComplexTypeReference(complexType, false);
serializer.WriteComplexValue(complexValue, complexTypeRef, false, false, new DuplicatePropertyNamesChecker(false, true));
});
result.Should().NotContain("\"@Annotation.1\":true,\"@Annotation.2\":123,\"@Annotation.3\":\"annotation\"");
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:23,代码来源:ODataJsonLightValueSerializerTests.cs
示例19: WritingInstanceAnnotationInComplexValueShouldWrite
public void WritingInstanceAnnotationInComplexValueShouldWrite()
{
var complexType = new EdmComplexType("TestNamespace", "Address");
model.AddElement(complexType);
settings.ShouldIncludeAnnotation = ODataUtils.CreateAnnotationFilter("*");
var result = this.SetupSerializerAndRunTest(serializer =>
{
var complexValue = new ODataComplexValue { TypeName = "TestNamespace.Address", InstanceAnnotations = new Collection<ODataInstanceAnnotation> { new ODataInstanceAnnotation("Is.ReadOnly", new ODataPrimitiveValue(true)) } };
var complexTypeRef = new EdmComplexTypeReference(complexType, false);
serializer.WriteComplexValue(complexValue, complexTypeRef, false, false, new DuplicatePropertyNamesChecker(false, true));
});
|
请发表评论