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); var customerOrders = new EdmNavigationPropertyInfo { Name = "Orders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many, }; var orderCustomer = new EdmNavigationPropertyInfo { Name = "Customer", Target = customerType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { orderCustomerId }, PrincipalProperties = customerType.Key() }; customerType.AddBidirectionalNavigation(customerOrders, orderCustomer); var customerLogins = new EdmNavigationPropertyInfo { Name = "Logins", Target = loginType, TargetMultiplicity = EdmMultiplicity.Many, }; var loginCustomer = new EdmNavigationPropertyInfo { Name = "Customer", Target = customerType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { loginCustomerIdProperty }, PrincipalProperties = customerType.Key() }; customerType.AddBidirectionalNavigation(customerLogins, loginCustomer); var customerHusband = new EdmNavigationPropertyInfo { Name = "Husband", Target = customerType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }; var customerWife = new EdmNavigationPropertyInfo { Name = "Wife", Target = customerType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }; customerType.AddBidirectionalNavigation(customerHusband, customerWife); var customerInfo = new EdmNavigationPropertyInfo { Name = "CustomerInfo", Target = customerInfoType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }; customerType.AddUnidirectionalNavigation(customerInfo); var productType = new EdmEntityType("NS1", "Product"); productType.AddKeys(productType.AddStructuralProperty("ProductId", EdmPrimitiveTypeKind.Int32, false)); productType.AddStructuralProperty("Description", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: true, maxLength: 1000, isUnicode: false)); productType.AddStructuralProperty("Dimensions", dimensionsTypeReference); productType.AddStructuralProperty("BaseConcurrency", EdmCoreModel.Instance.GetString(false), string.Empty, EdmConcurrencyMode.Fixed); productType.AddStructuralProperty("ComplexConcurrency", concurrencyInfoTypeReference); productType.AddStructuralProperty("NestedComplexConcurrency", auditInfoTypeReference); model.AddElement(productType); var barCodeType = new EdmEntityType("NS1", "Barcode"); barCodeType.AddKeys(barCodeType.AddStructuralProperty("Code", EdmCoreModel.Instance.GetBinary(isUnbounded: false, isNullable: false, maxLength: 50))); var barCodeProductIdProperty = barCodeType.AddStructuralProperty("ProductId", EdmPrimitiveTypeKind.Int32, false); barCodeType.AddStructuralProperty("Text", EdmPrimitiveTypeKind.String); model.AddElement(barCodeType); var productBarCodes = new EdmNavigationPropertyInfo { Name = "Barcodes", Target = barCodeType, TargetMultiplicity = EdmMultiplicity.Many }; var barCodeProduct = new EdmNavigationPropertyInfo { Name = "Product", Target = productType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { barCodeProductIdProperty }, PrincipalProperties = productType.Key() }; barCodeType.AddBidirectionalNavigation(barCodeProduct, productBarCodes); var incorrectScanType = new EdmEntityType("NS1", "IncorrectScan"); incorrectScanType.AddKeys(incorrectScanType.AddStructuralProperty("IncorrectScanId", EdmPrimitiveTypeKind.Int32, false)); var expectedCodeProperty = incorrectScanType.AddStructuralProperty("ExpectedCode", EdmCoreModel.Instance.GetBinary(isUnbounded: false, isNullable: false, maxLength: 50)); var actualCodeProperty = incorrectScanType.AddStructuralProperty("ActualCode", EdmCoreModel.Instance.GetBinary(isUnbounded: false, isNullable: true, maxLength: 50)); incorrectScanType.AddStructuralProperty("ScanDate", EdmPrimitiveTypeKind.DateTimeOffset); incorrectScanType.AddStructuralProperty("Details", EdmPrimitiveTypeKind.String); model.AddElement(incorrectScanType); var barCodeIncorrectScan = new EdmNavigationPropertyInfo { Name = "BadScans", Target = incorrectScanType, TargetMultiplicity = EdmMultiplicity.Many }; var incorrectScanExpectedBarCode = new EdmNavigationPropertyInfo { Name = "ExpectedBarcode", Target = barCodeType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { expectedCodeProperty }, PrincipalProperties = barCodeType.Key() }; incorrectScanType.AddBidirectionalNavigation(incorrectScanExpectedBarCode, barCodeIncorrectScan); var actualBarcode = new EdmNavigationPropertyInfo { Name = "ActualBarcode", Target = barCodeType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { actualCodeProperty }, PrincipalProperties = barCodeType.Key() }; incorrectScanType.AddUnidirectionalNavigation(actualBarcode); var barCodeDetailType = new EdmEntityType("NS1", "BarcodeDetail"); var codeProperty = barCodeDetailType.AddStructuralProperty("Code", EdmCoreModel.Instance.GetBinary(isUnbounded: false, isNullable: false, maxLength: 50)); barCodeDetailType.AddKeys(codeProperty); barCodeDetailType.AddStructuralProperty("RegisteredTo", EdmPrimitiveTypeKind.String); model.AddElement(barCodeDetailType); var barCodeDetail = new EdmNavigationPropertyInfo { Name = "Detail", Target = barCodeDetailType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = barCodeType.Key(), PrincipalProperties = barCodeDetailType.Key() }; barCodeType.AddUnidirectionalNavigation(barCodeDetail); var resolutionType = new EdmEntityType("NS1", "Resolution"); resolutionType.AddKeys(resolutionType.AddStructuralProperty("ResolutionId", EdmPrimitiveTypeKind.Int32, false)); resolutionType.AddStructuralProperty("Details", EdmPrimitiveTypeKind.String); model.AddElement(resolutionType); var complaintType = new EdmEntityType("NS1", "Complaint"); complaintType.AddKeys(complaintType.AddStructuralProperty("ComplaintId", EdmPrimitiveTypeKind.Int32, false)); var complaintCustomerId = complaintType.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(true)); complaintType.AddStructuralProperty("Logged", EdmPrimitiveTypeKind.DateTimeOffset); complaintType.AddStructuralProperty("Details", EdmPrimitiveTypeKind.String); model.AddElement(complaintType); var complaintCustomer = new EdmNavigationPropertyInfo { Name = "Customer", Target = customerType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { complaintCustomerId }, PrincipalProperties = customerType.Key() }; complaintType.AddUnidirectionalNavigation(complaintCustomer); var complaintResolution = new EdmNavigationPropertyInfo { Name = "Resolution", Target = resolutionType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }; var resolutionComplaint = new EdmNavigationPropertyInfo { Name = "Complaint", Target = complaintType, TargetMultiplicity = EdmMultiplicity.One }; complaintType.AddBidirectionalNavigation(complaintResolution, resolutionComplaint); var smartCardType = new EdmEntityType("NS1", "SmartCard"); var smartCardUsername = smartCardType.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 50, isUnicode: false)); smartCardType.AddKeys(smartCardUsername); smartCardType.AddStructuralProperty("CardSerial", EdmPrimitiveTypeKind.String); smartCardType.AddStructuralProperty("Issued", EdmPrimitiveTypeKind.DateTimeOffset); model.AddElement(smartCardType); var smartCardLogin = new EdmNavigationPropertyInfo { Name = "Login", Target = loginType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { smartCardUsername }, PrincipalProperties = loginType.Key() }; smartCardType.AddUnidirectionalNavigation(smartCardLogin); var smartCardLastLogin = new EdmNavigationPropertyInfo { Name = "LastLogin", Target = lastLoginType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }; smartCardType.AddUnidirectionalNavigation(smartCardLastLogin); var rsaTokenType = new EdmEntityType("NS1", "RSAToken"); rsaTokenType.AddKeys(rsaTokenType.AddStructuralProperty("Serial", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 20, isUnicode: false))); rsaTokenType.AddStructuralProperty("Issued", EdmPrimitiveTypeKind.DateTimeOffset); model.AddElement(rsaTokenType); var rsaTokenLogin = new EdmNavigationPropertyInfo { Name = "Login", Target = loginType, TargetMultiplicity = EdmMultiplicity.One }; rsaTokenType.AddUnidirectionalNavigation(rsaTokenLogin); var passwordResetType = new EdmEntityType("NS1", "PasswordReset"); passwordResetType.AddKeys(passwordResetType.AddStructuralProperty("ResetNo", EdmPrimitiveTypeKind.Int32, false)); var passwordResetUsername = passwordResetType.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 50, isUnicode: false)); passwordResetType.AddStructuralProperty("TempPassword", EdmPrimitiveTypeKind.String); passwordResetType.AddStructuralProperty("EmailedTo", EdmPrimitiveTypeKind.String); model.AddElement(passwordResetType); var passwordResetLogin = new EdmNavigationPropertyInfo { Name = "Login", Target = loginType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { passwordResetUsername }, PrincipalProperties = loginType.Key() }; passwordResetType.AddUnidirectionalNavigation(passwordResetLogin); var pageViewType = new EdmEntityType("NS1", "PageView"); pageViewType.AddKeys(pageViewType.AddStructuralProperty("PageViewId", EdmPrimitiveTypeKind.Int32, false)); var pageViewUsername = pageViewType.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 50, isUnicode: false)); pageViewType.AddStructuralProperty("Viewed", EdmPrimitiveTypeKind.DateTimeOffset); pageViewType.AddStructuralProperty("PageUrl", EdmCoreModel.Instance.GetString(isUnbounded: false, isNullable: false, maxLength: 500, isUnicode: false)); model.AddElement(pageViewType); var pageViewLogin = new EdmNavigationPropertyInfo { Name = "Login", Target = loginType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { pageViewUsername }, PrincipalProperties = loginType.Key() }; pageViewType.AddUnidirectionalNavigation(pageViewLogin); var productPageViewType = new EdmEntityType("NS1", "ProductPageView", pageViewType); var productPageViewProductId = productPageViewType.AddStructuralProperty("ProductId", EdmPrimitiveTypeKind.Int32, false); model.AddElement(productPageViewType); var productPageViewProduct = new EdmNavigationPropertyInfo { Name = "Product", Target = productType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productPageViewProductId }, PrincipalProperties = productType.Key() }; productPageViewType.AddUnidirectionalNavigation(productPageViewProduct); var supplierType = new EdmEntityType("NS1", "Supplier"); supplierType.AddKeys(supplierType.AddStructuralProperty("SupplierId", EdmPrimitiveTypeKind.Int32, false)); supplierType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String); model.AddElement(supplierType); var supplierProducts = new EdmNavigationPropertyInfo { Name = "Products", Target = productType, TargetMultiplicity = EdmMultiplicity.Many }; var productSuppliers = new EdmNavigationPropertyInfo { Name = "Suppliers", Target = supplierType, TargetMultiplicity = EdmMultiplicity.Many }; supplierType.AddBidirectionalNavigation(supplierProducts, productSuppliers); var supplierLogoType = new EdmEntityType("NS1", "SupplierLogo"); var supplierLogoSupplierId = supplierLogoType.AddStructuralProperty("SupplierId", EdmPrimitiveTypeKind.Int32, false); supplierLogoType.AddKeys(supplierLogoSupplierId); supplierLogoType.AddStructuralProperty("Logo", EdmCoreModel.Instance.GetBinary(isNullable: false, isUnbounded: false, maxLength: 500)); model.AddElement(supplierLogoType); var supplierSupplierLogo = new EdmNavigationPropertyInfo { Name = "Logo", Target = supplierLogoType, TargetMultiplicity = EdmMultiplicity.One, PrincipalProperties = new[] { supplierLogoSupplierId }, DependentProperties = supplierType.Key() }; supplierType.AddUnidirectionalNavigation(supplierSupplierLogo); var supplierInfoType = new EdmEntityType("NS1", "SupplierInfo"); supplierInfoType.AddKeys(supplierInfoType.AddStructuralProperty("SupplierInfoId", EdmPrimitiveTypeKind.Int32, false)); supplierInfoType.AddStructuralProperty("Information", EdmPrimitiveTypeKind.String); model.AddElement(supplierInfoType); var supplierInfoSupplier = new EdmNavigationPropertyInfo { Name = "Supplier", Target = supplierType, TargetMultiplicity = EdmMultiplicity.One, OnDelete = EdmOnDeleteAction.Cascade }; supplierInfoType.AddUnidirectionalNavigation(supplierInfoSupplier); var orderNoteType = new EdmEntityType("NS1", "OrderNote"); orderNoteType.AddKeys(orderNoteType.AddStructuralProperty("NoteId", EdmPrimitiveTypeKind.Int32, false)); orderNoteType.AddStructuralProperty("Note", EdmPrimitiveTypeKind.String); model.AddElement(orderNoteType); var orderNoteOrder = new EdmNavigationPropertyInfo { Name = "Order", Target = orderType, TargetMultiplicity = EdmMultiplicity.One }; var orderOrderNotes = new EdmNavigationPropertyInfo { Name = "Notes", Target = orderNoteType, TargetMultiplicity = EdmMultiplicity.Many, OnDelete = EdmOnDeleteAction.Cascade }; orderNoteType.AddBidirectionalNavigation(orderNoteOrder, orderOrderNotes); var orderQualityCheckType = new EdmEntityType("NS1", "OrderQualityCheck"); var orderQualityCheckOrderId = orderQualityCheckType.AddStructuralProperty("OrderId", EdmPrimitiveTypeKind.Int32, false); orderQualityCheckType.AddKeys(orderQualityCheckOrderId); orderQualityCheckType.AddStructuralProperty("CheckedBy", EdmPrimitiveTypeKind.String); orderQualityCheckType.AddStructuralProperty("CheckedDateTime", EdmPrimitiveTypeKind.DateTimeOffset); model.AddElement(orderQualityCheckType); var orderQualityCheckOrder = new EdmNavigationPropertyInfo { Name = "Order", Target = orderType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderQualityCheckOrderId }, PrincipalProperties = orderType.Key() }; orderQualityCheckType.AddUnidirectionalNavigation(orderQualityCheckOrder); var orderLineType = new EdmEntityType("NS1", "OrderLine"); var orderLineOrderId = orderLineType.AddStructuralProperty("OrderId", EdmPrimitiveTypeKind.Int32, false); var orderLineProductId = orderLineType.AddStructuralProperty("ProductId", EdmPrimitiveTypeKind.Int32, false); orderLineType.AddKeys(orderLineOrderId, orderLineProductId); orderLineType.AddStructuralProperty("Quantity", EdmPrimitiveTypeKind.Int32); orderLineType.AddStructuralProperty("ConcurrencyToken", EdmCoreModel.Instance.GetString(false), string.Empty, EdmConcurrencyMode.Fixed); model.AddElement(orderLineType); var orderLineOrder = new EdmNavigationPropertyInfo { Name = "Order", Target = orderType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderLineOrderId }, PrincipalProperties = orderType.Key() }; var orderOrderLine = new EdmNavigationPropertyInfo { Name = "OrderLines", Target = orderLineType, TargetMultiplicity = EdmMultiplicity.Many }; orderLineType.AddBidirectionalNavigation(orderLineOrder, orderOrderLine); var orderLineProduct = new EdmNavigationPropertyInfo { Name = "Product", Target = productType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderLineProductId }, PrincipalProperties = productType.Key() }; orderLineType.AddUnidirectionalNavigation(orderLineProduct); var backOrderLineType = new EdmEntityType("NS1", "BackOrderLine", orderLineType); backOrderLineType.AddStructuralProperty("ETA", EdmPrimitiveTypeKind.DateTimeOffset); model.AddElement(backOrderLineType); var backOrderLineSupplier = new EdmNavigationPropertyInfo { Name = "Supplier", Target = supplierType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }; var supplierBackOrderLines = new EdmNavigationPropertyInfo { Name = "BackOrderLines", Target = backOrderLineType, TargetMultiplicity = EdmMultiplicity.Many }; backOrderLineType.AddBidirectionalNavigation(backOrderLineSupplier, supplierBackOrderLines); var backOrderLine2Type = new EdmEntityType("NS1", "BackOrderLine2", backOrderLineType); model.AddElement(backOrderLine2Type); var discontinuedProductType = new EdmEntityType("NS1", "DiscontinuedProduct", productType); discontinuedProductType.AddStructuralProperty("Discontinued", EdmPrimitiveTypeKind.DateTimeOffset); var replacementProductId = discontinuedProductType.AddStructuralProperty("ReplacementProductId", EdmCoreModel.Instance.GetInt32(true)); model.AddElement(discontinuedProductType); var discontinuedProductReplacement = new EdmNavigationPropertyInfo { Name = "ReplacedBy", Target = productType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { replacementProductId }, PrincipalProperties = productType.Key() }; var productReplaces = new EdmNavigationPropertyInfo { Name = "Replaces", Target = discontinuedProductType, TargetMultiplicity = EdmMultiplicity.Many, }; discontinuedProductType.AddBidirectionalNavigation(discontinuedProductReplacement, productReplaces); var productDetailType = new EdmEntityType("NS1", "ProductDetail"); var productDetailProductId = productDetailType.AddStructuralProperty("ProductId", EdmPrimitiveTypeKind.Int32, false); productDetailType.AddKeys(productDetailProductId); productDetailType.AddStructuralProperty("Details", EdmPrimitiveTypeKind.String); model.AddElement(productDetailType); var productDetailProduct = new EdmNavigationPropertyInfo { Name = "Product", Target = productType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productDetailProductId }, PrincipalProperties = productType.Key() }; var productProductDetail = new EdmNavigationPropertyInfo { Name = "Detail", Target = productDetailType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }; productDetailType.AddBidirectionalNavigation(productDetailProduct, productProductDetail); var productReviewType = new EdmEntityType("NS1", "ProductReview"); var productReviewProductId = productReviewType.AddStructuralProperty("ProductId", EdmPrimitiveTypeKind.Int32, false); productReviewType.AddKeys(productReviewProductId, productReviewType.AddStructuralProperty("ReviewId", EdmPrimitiveTypeKind.Int32, false)); productReviewType.AddStructuralProperty("Review", EdmPrimitiveTypeKind.String); model.AddElement(productReviewType); var productReviewProduct = new EdmNavigationPropertyInfo { Name = "Product", Target = productType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productReviewProductId }, PrincipalProperties = productType.Key() }; var productProductReviews = new EdmNavigationPropertyInfo { Name = "Reviews", Target = productReviewType, TargetMultiplicity = EdmMultiplicity.Many }; productReviewType.AddBidirectionalNavigation(productReviewProduct, productProductReviews); var productPhotoType = new EdmEntityType("NS1", "ProductPhoto"); var productPhotoProductId = productPhotoType.AddStructuralProperty("ProductId", EdmPrimitiveTypeKind.Int32, false); productPhotoType.AddKeys(productPhotoProductId, productPhotoType.AddStructuralProperty("PhotoId", EdmPrimitiveTypeKind.Int32, false)); productPhotoType.AddStructuralProperty("Photo", EdmPrimitiveTypeKind.Binary); model.AddElement(productPhotoType); var productProductPhotos = new EdmNavigationPropertyInfo { Name = "Photos", Target = productPhotoType, TargetMultiplicity = EdmMultiplicity.Many }; var productPhotoProduct = new EdmNavigationPropertyInfo { Name = "Product", Target = productType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productPhotoProductId }, PrincipalProperties = productType.Key() }; productType.AddBidirectionalNavigation(productProductPhotos, productPhotoProduct); var productWebFeatureType = new EdmEntityType("NS1", "ProductWebFeature"); productWebFeatureType.AddKeys(productWebFeatureType.AddStructuralProperty("FeatureId", EdmPrimitiveTypeKind.Int32, false)); var productWebFeatureProductId = productWebFeatureType.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(true)); var productWebFeaturePhotoId = productWebFeatureType.AddStructuralProperty("PhotoId", EdmCoreModel.Instance.GetInt32(true)); var productWebFeatureReviewId = productWebFeatureType.AddStructuralProperty("ReviewId", EdmCoreModel.Instance.GetInt32(true)); productWebFeatureType.AddStructuralProperty("Heading", EdmPrimitiveTypeKind.String); model.AddElement(productWebFeatureType); var productReviewWebFeatures = new EdmNavigationPropertyInfo { Name = "Features", Target = productWebFeatureType, TargetMultiplicity = EdmMultiplicity.Many }; var productWebFeatureReview = new EdmNavigationPropertyInfo { Name = "Review", Target = productReviewType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { productWebFeatureReviewId, productWebFeatureProductId }, PrincipalProperties = productReviewType.Key() }; productWebFeatureType.AddBidirectionalNavigation(productWebFeatureReview, productReviewWebFeatures); var productPhotoWebFeatures = new EdmNavigationPropertyInfo { Name = "Features", Target = productWebFeatureType, TargetMultiplicity = EdmMultiplicity.Many }; var productWebFeaturePhoto = new EdmNavigationPropertyInfo { Name = "Photo", Target = productPhotoType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { productWebFeaturePhotoId, productWebFeatureProductId }, PrincipalProperties = productPhotoType.Key() }; productWebFeatureType.AddBidirectionalNavigation(productWebFeaturePhoto, productPhotoWebFeatures); var computerType = new EdmEntityType("NS1", "Computer"); computerType.AddKeys(computerType.AddStructuralProperty("ComputerId", EdmPrimitiveTypeKind.Int32, false)); computerType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String); model.AddElement(computerType); var computerDetailType = new EdmEntityType("NS1", "ComputerDetail"); computerDetailType.AddKeys(computerDetailType.AddStructuralProperty("ComputerDetailId", EdmPrimitiveTypeKind.Int32, false)); computerDetailType.AddStructuralProperty("Model", EdmPrimitiveTypeKind.String); computerDetailType.AddStructuralProperty("Serial", EdmPrimitiveTypeKind.String); computerDetailType.AddStructuralProperty("Specifications", EdmPrimitiveTypeKind.String); computerDetailType.AddStructuralProperty("PurchaseDate", EdmPrimitiveTypeKind.DateTimeOffset); computerDetailType.AddStructuralProperty("Dimensions", dimensionsTypeReference); model.AddElement(computerDetailType); var computerDetailComputer = new EdmNavigationPropertyInfo { Name = "Computer", Target = computerType, TargetMultiplicity = EdmMultiplicity.One }; var computerComputerDetail = new EdmNavigationPropertyInfo { Name = "ComputerDetail", Target = computerDetailType, TargetMultiplicity = EdmMultiplicity.One }; computerType.AddBidirectionalNavigation(computerComputerDetail, computerDetailComputer); var driverType = new EdmEntityType("NS1", "Driver"); driverType.AddKeys(driverType.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 100, isNullable: false, isUnicode: false))); driverType.AddStructuralProperty("BirthDate", EdmPrimitiveTypeKind.DateTimeOffset); model.AddElement(driverType); var licenseType = new EdmEntityType("NS1", "License"); var licenseDriverName = licenseType.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 100, isNullable: false, isUnicode: false)); licenseType.AddKeys(licenseDriverName); licenseType.AddStructuralProperty("LicenseNumber", EdmPrimitiveTypeKind.String); licenseType.AddStructuralProperty("LicenseClass", EdmPrimitiveTypeKind.String); licenseType.AddStructuralProperty("Restrictions", EdmPrimitiveTypeKind.String); licenseType.AddStructuralProperty("ExpirationDate", EdmPrimitiveTypeKind.DateTimeOffset); model.AddElement(licenseType); var driverLicense = new EdmNavigationPropertyInfo { Name = "License", Target = licenseType, TargetMultiplicity = EdmMultiplicity.One, }; var licenseDriver = new EdmNavigationPropertyInfo { Name = "Driver", Target = driverType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { licenseDriverName }, PrincipalProperties = driverType.Key() }; licenseType.AddBidirectionalNavigation(licenseDriver, driverLicense); #endregion model.AddDefaultContainerFixup("NS1"); return model; }
public static IEdmModel ModelWithAllConceptsEdm() { var stringType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.String); var model = new EdmModel(); var addressType = new EdmComplexType("NS1", "Address"); addressType.AddStructuralProperty("Street", EdmPrimitiveTypeKind.String); addressType.AddStructuralProperty("City", new EdmStringTypeReference(stringType, /*isNullable*/false, /*isUnbounded*/false, /*maxLength*/30, /*isUnicode*/true)); model.AddElement(addressType); var zipCodeType = new EdmComplexType("NS1", "ZipCode"); zipCodeType.AddStructuralProperty("Main", new EdmStringTypeReference(stringType, /*isNullable*/false, /*isUnbounded*/false, /*maxLength*/5, /*isUnicode*/false)); zipCodeType.AddStructuralProperty("Extended", new EdmStringTypeReference(stringType, /*isNullable*/true, /*isUnbounded*/false, /*maxLength*/5, /*isUnicode*/false)); model.AddElement(zipCodeType); addressType.AddStructuralProperty("Zip", new EdmComplexTypeReference(zipCodeType, false)); var foreignAddressType = new EdmComplexType("NS1", "ForeignAddress", addressType, false); foreignAddressType.AddStructuralProperty("State", EdmPrimitiveTypeKind.String); model.AddElement(foreignAddressType); var personType = new EdmEntityType("NS1", "Person", null, true, false); personType.AddKeys(personType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, false)); model.AddElement(personType); var customerType = new EdmEntityType("NS1", "Customer", personType); customerType.AddStructuralProperty("IsVIP", EdmPrimitiveTypeKind.Boolean); customerType.AddProperty(new EdmStructuralProperty(customerType, "LastUpdated", EdmCoreModel.Instance.GetDateTimeOffset(false), null, EdmConcurrencyMode.Fixed)); customerType.AddStructuralProperty("BillingAddress", new EdmComplexTypeReference(addressType, false)); customerType.AddStructuralProperty("ShippingAddress", new EdmComplexTypeReference(addressType, false)); model.AddElement(customerType); var orderType = new EdmEntityType("NS1", "Order"); orderType.AddKeys(orderType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, false)); var customerIdProperty = orderType.AddStructuralProperty("CustomerId", EdmPrimitiveTypeKind.Int32, false); model.AddElement(orderType); var navProp1 = new EdmNavigationPropertyInfo { Name = "ToOrders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many, }; var navProp2 = new EdmNavigationPropertyInfo { Name = "ToCustomer", Target = customerType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { customerIdProperty }, PrincipalProperties = customerType.Key() }; customerType.AddBidirectionalNavigation(navProp1, navProp2); var container = new EdmEntityContainer("NS1", "MyContainer"); container.AddEntitySet("PersonSet", personType); container.AddEntitySet("OrderSet", orderType); model.AddElement(container); var function = new EdmFunction("NS1", "Function1", EdmCoreModel.Instance.GetInt64(true)); function.AddParameter("Param1", EdmCoreModel.Instance.GetInt32(true)); container.AddFunctionImport(function); model.AddElement(function); return model; }
public static IEdmModel AssociationOnDeleteModelEdm() { var model = new EdmModel(); var customerType = new EdmEntityType("NS1", "Customer"); customerType.AddKeys(customerType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32)); model.AddElement(customerType); var orderType = new EdmEntityType("NS1", "Order"); orderType.AddKeys(orderType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32)); model.AddElement(orderType); var customerIdProperty = orderType.AddStructuralProperty("CustomerId", EdmPrimitiveTypeKind.Int32); var navProp1 = new EdmNavigationPropertyInfo { Name = "ToOrders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many, OnDelete = EdmOnDeleteAction.Cascade }; var navProp2 = new EdmNavigationPropertyInfo { Name = "ToCustomer", Target = customerType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { customerIdProperty }, PrincipalProperties = customerType.Key(), OnDelete = EdmOnDeleteAction.None }; customerType.AddBidirectionalNavigation(navProp1, navProp2); return model; }
public static IEdmModel AssociationFkEdm() { var model = new EdmModel(); var customerType = new EdmEntityType("NS1", "Customer"); customerType.AddKeys(customerType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32)); model.AddElement(customerType); var orderType = new EdmEntityType("NS1", "Order"); orderType.AddKeys(orderType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32)); var orderTypeCustomerId = orderType.AddStructuralProperty("CustomerId", EdmPrimitiveTypeKind.Int32); model.AddElement(orderType); customerType.AddUnidirectionalNavigation( new EdmNavigationPropertyInfo { Name = "ToOrders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many, }); orderType.AddUnidirectionalNavigation( new EdmNavigationPropertyInfo { Name = "Customer", Target = customerType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderTypeCustomerId }, PrincipalProperties = orderType.Key() }); return model; }
public static IEdmModel AssociationCompositeFkEdm() { var model = new EdmModel(); var customerType = new EdmEntityType("NS1", "Customer"); customerType.AddKeys(customerType.AddStructuralProperty("Id1", EdmPrimitiveTypeKind.Int32)); customerType.AddKeys(customerType.AddStructuralProperty("Id2", EdmPrimitiveTypeKind.Int32)); model.AddElement(customerType); var orderType = new EdmEntityType("NS1", "Order"); orderType.AddKeys(orderType.AddStructuralProperty("Id1", EdmPrimitiveTypeKind.Int32)); var customerId1Property = orderType.AddStructuralProperty("CustomerId1", EdmPrimitiveTypeKind.Int32); var customerId2Property = orderType.AddStructuralProperty("CustomerId2", EdmPrimitiveTypeKind.Int32); model.AddElement(orderType); var navProp = new EdmNavigationPropertyInfo { Name = "ToCustomer", Target = customerType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { customerId1Property, customerId2Property }, PrincipalProperties = customerType.Key() }; orderType.AddUnidirectionalNavigation(navProp); return model; }
public static IEdmModel MultipleNamespacesEdm() { var model = new EdmModel(); var personType = new EdmEntityType("NS1", "Person"); personType.AddKeys(personType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32)); model.AddElement(personType); var complexType1 = new EdmComplexType("NS3", "ComplexLevel1"); model.AddElement(complexType1); var complexType2 = new EdmComplexType("NS2", "ComplexLevel2"); model.AddElement(complexType2); var complexType3 = new EdmComplexType("NS2", "ComplexLevel3"); model.AddElement(complexType3); complexType3.AddStructuralProperty("IntProperty", EdmPrimitiveTypeKind.Int32); complexType2.AddStructuralProperty("ComplexProperty", new EdmComplexTypeReference(complexType3, false)); complexType1.AddStructuralProperty("ComplexProperty", new EdmComplexTypeReference(complexType2, false)); personType.AddStructuralProperty("ComplexProperty", new EdmComplexTypeReference(complexType1, false)); var customerType = new EdmEntityType("NS3", "Customer", personType); model.AddElement(customerType); var orderType = new EdmEntityType("NS2", "Order"); orderType.AddKeys(orderType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32)); model.AddElement(orderType); var customerIdProperty = orderType.AddStructuralProperty("CustomerId", EdmPrimitiveTypeKind.Int32); var navProp1 = new EdmNavigationPropertyInfo { Name = "ToOrders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many, }; var navProp2 = new EdmNavigationPropertyInfo { Name = "ToCustomer", Target = customerType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { customerIdProperty }, PrincipalProperties = customerType.Key() }; customerType.AddBidirectionalNavigation(navProp1, navProp2); return model; }
public void ConstructibleModelODataTestModelDefaultModel() { EdmModel model = new EdmModel(); EdmComplexType aliases = new EdmComplexType("DefaultNamespace", "Aliases"); EdmStructuralProperty aliasesAlternativeNames = aliases.AddStructuralProperty("AlternativeNames", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false, 10, null, false))); model.AddElement(aliases); EdmComplexType phone = new EdmComplexType("DefaultNamespace", "Phone"); EdmStructuralProperty phoneNumber = phone.AddStructuralProperty("PhoneNumber", EdmCoreModel.Instance.GetString(false, 16, null, false)); EdmStructuralProperty phoneExtension = phone.AddStructuralProperty("Extension", EdmCoreModel.Instance.GetString(false, 16, null, true)); model.AddElement(phone); EdmComplexType contact = new EdmComplexType("DefaultNamespace", "ContactDetails"); EdmStructuralProperty contactEmailBag = contact.AddStructuralProperty("EmailBag", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false, 32, null, false))); EdmStructuralProperty contactAlternativeNames = contact.AddStructuralProperty("AlternativeNames", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false, 10, null, false))); EdmStructuralProperty contactAlias = contact.AddStructuralProperty("ContactAlias", new EdmComplexTypeReference(aliases, false)); EdmStructuralProperty contactHomePhone = contact.AddStructuralProperty("HomePhone", new EdmComplexTypeReference(phone, false)); EdmStructuralProperty contactWorkPhone = contact.AddStructuralProperty("WorkPhone", new EdmComplexTypeReference(phone, false)); EdmStructuralProperty contactMobilePhoneBag = contact.AddStructuralProperty("MobilePhoneBag", EdmCoreModel.GetCollection(new EdmComplexTypeReference(phone, false))); model.AddElement(contact); EdmComplexType category = new EdmComplexType("DefaultNamespace", "ComplexToCategory"); EdmStructuralProperty categoryTerm = category.AddStructuralProperty("Term", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty categoryScheme = category.AddStructuralProperty("Scheme", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty categoryLabel = category.AddStructuralProperty("Label", EdmCoreModel.Instance.GetString(false)); model.AddElement(category); EdmComplexType dimensions = new EdmComplexType("DefaultNamespace", "Dimensions"); EdmStructuralProperty dimensionsWidth = dimensions.AddStructuralProperty("Width", EdmCoreModel.Instance.GetDecimal(10, 3, false)); EdmStructuralProperty dimensionsHeight = dimensions.AddStructuralProperty("Height", EdmCoreModel.Instance.GetDecimal(10, 3, false)); EdmStructuralProperty dimensionsDepth = dimensions.AddStructuralProperty("Depth", EdmCoreModel.Instance.GetDecimal(10, 3, false)); model.AddElement(dimensions); EdmComplexType concurrency = new EdmComplexType("DefaultNamespace", "ConcurrencyInfo"); EdmStructuralProperty concurrencyToken = concurrency.AddStructuralProperty("Token", EdmCoreModel.Instance.GetString(false, 20, null, false)); EdmStructuralProperty concurrencyQueriedDateTime = concurrency.AddStructuralProperty("QueriedDateTime", EdmCoreModel.Instance.GetDateTimeOffset(true)); model.AddElement(concurrency); EdmComplexType audit = new EdmComplexType("DefaultNamespace", "AuditInfo"); EdmStructuralProperty auditModifiedDate = audit.AddStructuralProperty("ModifiedDate", EdmCoreModel.Instance.GetDateTimeOffset(false)); EdmStructuralProperty auditModifiedBy = audit.AddStructuralProperty("ModifiedBy", EdmCoreModel.Instance.GetString(false, 50, null, false)); EdmStructuralProperty auditConcurrency = audit.AddStructuralProperty("Concurrency", new EdmComplexTypeReference(concurrency, false)); model.AddElement(audit); EdmEntityType customer = new EdmEntityType("DefaultNamespace", "Customer"); EdmStructuralProperty customerId = customer.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(false)); customer.AddKeys(customerId); EdmStructuralProperty customerName = customer.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false, 100, null, false)); EdmStructuralProperty customerPrimaryContact = customer.AddStructuralProperty("PrimaryContactInfo", new EdmComplexTypeReference(contact, false)); EdmStructuralProperty customerBackupContact = customer.AddStructuralProperty("BackupContactInfo", EdmCoreModel.GetCollection(new EdmComplexTypeReference(contact, false))); EdmStructuralProperty customerAuditing = customer.AddStructuralProperty("Auditing", new EdmComplexTypeReference(audit, false)); EdmStructuralProperty customerThumbnail = customer.AddStructuralProperty("Thumbnail", EdmCoreModel.Instance.GetStream(false)); EdmStructuralProperty customerVideo = customer.AddStructuralProperty("Video", EdmCoreModel.Instance.GetStream(false)); model.AddElement(customer); EdmEntityType barcode = new EdmEntityType("DefaultNamespace", "Barcode"); EdmStructuralProperty barcodeCode = barcode.AddStructuralProperty("Code", EdmCoreModel.Instance.GetInt32(false)); barcode.AddKeys(barcodeCode); EdmStructuralProperty barcodeProductId = barcode.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty barcodeText = barcode.AddStructuralProperty("Text", EdmCoreModel.Instance.GetString(false)); model.AddElement(barcode); EdmEntityType incorrectScan = new EdmEntityType("DefaultNamespace", "IncorrectScan"); EdmStructuralProperty incorrectScanId = incorrectScan.AddStructuralProperty("IncorrectScanId", EdmCoreModel.Instance.GetInt32(false)); incorrectScan.AddKeys(incorrectScanId); EdmStructuralProperty incorrectScanExpectedCode = incorrectScan.AddStructuralProperty("ExpectedCode", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty incorrectScanActualCode = incorrectScan.AddStructuralProperty("ActualCode", EdmCoreModel.Instance.GetInt32(true)); EdmStructuralProperty incorrectScanDate = incorrectScan.AddStructuralProperty("ScanDate", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetDateTimeOffset(false))); EdmStructuralProperty incorrectScanDetails = incorrectScan.AddStructuralProperty("Details", EdmCoreModel.Instance.GetString(false)); model.AddElement(incorrectScan); EdmEntityType barcodeDetail = new EdmEntityType("DefaultNamespace", "BarcodeDetail"); EdmStructuralProperty barcodeDetailCode = barcodeDetail.AddStructuralProperty("Code", EdmCoreModel.Instance.GetInt32(false)); barcodeDetail.AddKeys(barcodeDetailCode); EdmStructuralProperty barcodeDetailRegisteredTo = barcodeDetail.AddStructuralProperty("RegisteredTo", EdmCoreModel.Instance.GetString(false)); model.AddElement(barcodeDetail); EdmEntityType complaint = new EdmEntityType("DefaultNamespace", "Complaint"); EdmStructuralProperty complaintId = complaint.AddStructuralProperty("ComplaintId", EdmCoreModel.Instance.GetInt32(false)); complaint.AddKeys(complaintId); EdmStructuralProperty complaintCustomerId = complaint.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(true)); EdmStructuralProperty complaintLogged = complaint.AddStructuralProperty("Logged", EdmCoreModel.Instance.GetDateTimeOffset(false)); EdmStructuralProperty complaintDetails = complaint.AddStructuralProperty("Details", EdmCoreModel.Instance.GetString(false)); model.AddElement(complaint); EdmEntityType resolution = new EdmEntityType("DefaultNamespace", "Resolution"); EdmStructuralProperty resolutionId = resolution.AddStructuralProperty("ResolutionId", EdmCoreModel.Instance.GetInt32(false)); resolution.AddKeys(resolutionId); EdmStructuralProperty resolutionDetails = resolution.AddStructuralProperty("Details", EdmCoreModel.Instance.GetString(false)); model.AddElement(resolution); EdmEntityType login = new EdmEntityType("DefaultNamespace", "Login"); EdmStructuralProperty loginUsername = login.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false)); login.AddKeys(loginUsername); EdmStructuralProperty loginCustomerId = login.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(false)); model.AddElement(login); EdmEntityType suspiciousActivity = new EdmEntityType("DefaultNamespace", "SuspiciousActivity"); EdmStructuralProperty suspiciousActivityId = suspiciousActivity.AddStructuralProperty("SuspiciousActivityId", EdmCoreModel.Instance.GetInt32(false)); suspiciousActivity.AddKeys(suspiciousActivityId); EdmStructuralProperty suspiciousActivityProperty = suspiciousActivity.AddStructuralProperty("Activity", EdmCoreModel.Instance.GetString(false)); model.AddElement(suspiciousActivity); EdmEntityType smartCard = new EdmEntityType("DefaultNamespace", "SmartCard"); EdmStructuralProperty smartCardUsername = smartCard.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false)); smartCard.AddKeys(smartCardUsername); EdmStructuralProperty smartCardSerial = smartCard.AddStructuralProperty("CardSerial", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty smartCardIssued = smartCard.AddStructuralProperty("Issued", EdmCoreModel.Instance.GetDateTimeOffset(false)); model.AddElement(smartCard); EdmEntityType rsaToken = new EdmEntityType("DefaultNamespace", "RSAToken"); EdmStructuralProperty rsaTokenSerial = rsaToken.AddStructuralProperty("Serial", EdmCoreModel.Instance.GetString(false, 20, null, false)); rsaToken.AddKeys(rsaTokenSerial); EdmStructuralProperty rsaTokenIssued = rsaToken.AddStructuralProperty("Issued", EdmCoreModel.Instance.GetDateTimeOffset(false)); model.AddElement(rsaToken); EdmEntityType passwordReset = new EdmEntityType("DefaultNamespace", "PasswordReset"); EdmStructuralProperty passwordResetNo = passwordReset.AddStructuralProperty("ResetNo", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty passwordResetUsername = passwordReset.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false)); passwordReset.AddKeys(passwordResetNo); passwordReset.AddKeys(passwordResetUsername); EdmStructuralProperty passwordResetTempPassword = passwordReset.AddStructuralProperty("TempPassword", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty passwordResetEmailedTo = passwordReset.AddStructuralProperty("EmailedTo", EdmCoreModel.Instance.GetString(false)); model.AddElement(passwordReset); EdmEntityType pageView = new EdmEntityType("DefaultNamespace", "PageView"); EdmStructuralProperty pageViewId = pageView.AddStructuralProperty("PageViewId", EdmCoreModel.Instance.GetInt32(false)); pageView.AddKeys(pageViewId); EdmStructuralProperty pageViewUsername = pageView.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false)); EdmStructuralProperty pageViewed = pageView.AddStructuralProperty("Viewed", EdmCoreModel.Instance.GetDateTimeOffset(false)); EdmStructuralProperty pageViewPageUrl = pageView.AddStructuralProperty("PageUrl", EdmCoreModel.Instance.GetString(false, 500, null, false)); model.AddElement(pageView); EdmEntityType productPageView = new EdmEntityType("DefaultNamespace", "ProductPageView", pageView); EdmStructuralProperty productPageViewId = productPageView.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false)); model.AddElement(productPageView); EdmEntityType lastLogin = new EdmEntityType("DefaultNamespace", "LastLogin"); EdmStructuralProperty lastLoginUsername = lastLogin.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false)); lastLogin.AddKeys(lastLoginUsername); EdmStructuralProperty lastLoginLoggedIn = lastLogin.AddStructuralProperty("LoggedIn", EdmCoreModel.Instance.GetDateTimeOffset(false)); EdmStructuralProperty lastLoginLoggedOut = lastLogin.AddStructuralProperty("LoggedOut", EdmCoreModel.Instance.GetDateTimeOffset(true)); model.AddElement(lastLogin); EdmEntityType message = new EdmEntityType("DefaultNamespace", "Message"); EdmStructuralProperty messageId = message.AddStructuralProperty("MessageId", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty messageFromUsername = message.AddStructuralProperty("FromUsername", EdmCoreModel.Instance.GetString(false, 50, null, false)); message.AddKeys(messageId); message.AddKeys(messageFromUsername); EdmStructuralProperty messageToUsername = message.AddStructuralProperty("ToUsername", EdmCoreModel.Instance.GetString(false, 50, null, false)); EdmStructuralProperty messageSent = message.AddStructuralProperty("Sent", EdmCoreModel.Instance.GetDateTimeOffset(false)); EdmStructuralProperty messageSubject = message.AddStructuralProperty("Subject", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty messageBody = message.AddStructuralProperty("Body", EdmCoreModel.Instance.GetString(true)); EdmStructuralProperty messageIsRead = message.AddStructuralProperty("IsRead", EdmCoreModel.Instance.GetBoolean(false)); model.AddElement(message); EdmEntityType order = new EdmEntityType("DefaultNamespace", "Order"); EdmStructuralProperty orderId = order.AddStructuralProperty("OrderId", EdmCoreModel.Instance.GetInt32(false)); order.AddKeys(orderId); EdmStructuralProperty orderCustomerId = order.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(true)); EdmStructuralProperty orderConcurrency = order.AddStructuralProperty("Concurrency", new EdmComplexTypeReference(concurrency, false)); model.AddElement(order); EdmEntityType orderNote = new EdmEntityType("DefaultNamespace", "OrderNote"); EdmStructuralProperty orderNoteId = orderNote.AddStructuralProperty("NoteId", EdmCoreModel.Instance.GetInt32(false)); orderNote.AddKeys(orderNoteId); EdmStructuralProperty orderNoteDescription = orderNote.AddStructuralProperty("Note", EdmCoreModel.Instance.GetString(false)); model.AddElement(orderNote); EdmEntityType orderQualityCheck = new EdmEntityType("DefaultNamespace", "OrderQualityCheck"); EdmStructuralProperty orderQualityCheckId = orderQualityCheck.AddStructuralProperty("OrderId", EdmCoreModel.Instance.GetInt32(false)); orderQualityCheck.AddKeys(orderQualityCheckId); EdmStructuralProperty orderQualityCheckBy = orderQualityCheck.AddStructuralProperty("CheckedBy", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty orderQualityCheckDateTime = orderQualityCheck.AddStructuralProperty("CheckedDateTime", EdmCoreModel.Instance.GetDateTimeOffset(false)); model.AddElement(orderQualityCheck); EdmEntityType orderLine = new EdmEntityType("DefaultNamespace", "OrderLine"); EdmStructuralProperty orderLineOrderId = orderLine.AddStructuralProperty("OrderId", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty orderLineProductId = orderLine.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false)); orderLine.AddKeys(orderLineOrderId); orderLine.AddKeys(orderLineProductId); EdmStructuralProperty orderLineQuantity = orderLine.AddStructuralProperty("Quantity", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty orderLineConcurrencyToken = orderLine.AddStructuralProperty("ConcurrencyToken", EdmCoreModel.Instance.GetString(false), null, EdmConcurrencyMode.Fixed); EdmStructuralProperty orderLineStream = orderLine.AddStructuralProperty("OrderLineStream", EdmCoreModel.Instance.GetStream(false)); model.AddElement(orderLine); EdmEntityType backOrderLine = new EdmEntityType("DefaultNamespace", "BackOrderLine", orderLine); model.AddElement(backOrderLine); EdmEntityType backOrderLine2 = new EdmEntityType("DefaultNamespace", "BackOrderLine2", backOrderLine); model.AddElement(backOrderLine2); EdmEntityType product = new EdmEntityType("DefaultNamespace", "Product"); EdmStructuralProperty productId = product.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false)); product.AddKeys(productId); EdmStructuralProperty productDescription = product.AddStructuralProperty("Description", EdmCoreModel.Instance.GetString(false, 1000, true, true)); EdmStructuralProperty productDimensions = product.AddStructuralProperty("Dimensions", new EdmComplexTypeReference(dimensions, false)); EdmStructuralProperty productBaseConcurrency = new EdmStructuralProperty( product, "BaseConcurrency", EdmCoreModel.Instance.GetString(false), null, EdmConcurrencyMode.Fixed); product.AddProperty(productBaseConcurrency); EdmStructuralProperty productComplexConcurrency = product.AddStructuralProperty("ComplexConcurrency", new EdmComplexTypeReference(concurrency, false)); EdmStructuralProperty productNestedComplexConcurrency = product.AddStructuralProperty("NestedComplexConcurrency", new EdmComplexTypeReference(audit, false)); EdmStructuralProperty productPicture = product.AddStructuralProperty("Picture", EdmCoreModel.Instance.GetStream(false)); model.AddElement(product); EdmEntityType discontinuedProduct = new EdmEntityType("DefaultNamespace", "DiscontinuedProduct", product); EdmStructuralProperty discontinuedProductDate = discontinuedProduct.AddStructuralProperty("Discontinued", EdmCoreModel.Instance.GetDateTimeOffset(false)); EdmStructuralProperty discontinuedProductReplacementProductId = discontinuedProduct.AddStructuralProperty("ReplacementProductId", EdmCoreModel.Instance.GetInt32(true)); EdmStructuralProperty discontinuedProductDiscontinuedPhone = discontinuedProduct.AddStructuralProperty("DiscontinuedPhone", new EdmComplexTypeReference(phone, false)); model.AddElement(discontinuedProduct); EdmEntityType productDetail = new EdmEntityType("DefaultNamespace", "ProductDetail"); EdmStructuralProperty productDetailProductId = productDetail.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false)); productDetail.AddKeys(productDetailProductId); EdmStructuralProperty productDetails = productDetail.AddStructuralProperty("Details", EdmCoreModel.Instance.GetString(false)); model.AddElement(productDetail); EdmEntityType productReview = new EdmEntityType("DefaultNamespace", "ProductReview"); EdmStructuralProperty productReviewProductId = productReview.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty productReviewId = productReview.AddStructuralProperty("ReviewId", EdmCoreModel.Instance.GetInt32(false)); productReview.AddKeys(productReviewProductId); productReview.AddKeys(productReviewId); EdmStructuralProperty productReviewDescription = productReview.AddStructuralProperty("Review", EdmCoreModel.Instance.GetString(false)); model.AddElement(productReview); EdmEntityType productPhoto = new EdmEntityType("DefaultNamespace", "ProductPhoto"); EdmStructuralProperty productPhotoProductId = productPhoto.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty productPhotoId = productPhoto.AddStructuralProperty("PhotoId", EdmCoreModel.Instance.GetInt32(false)); productPhoto.AddKeys(productPhotoProductId); productPhoto.AddKeys(productPhotoId); EdmStructuralProperty productPhotoBinary = productPhoto.AddStructuralProperty("Photo", EdmCoreModel.Instance.GetBinary(false)); model.AddElement(productPhoto); EdmEntityType productWebFeature = new EdmEntityType("DefaultNamespace", "ProductWebFeature"); EdmStructuralProperty productWebFeatureId = productWebFeature.AddStructuralProperty("FeatureId", EdmCoreModel.Instance.GetInt32(false)); productWebFeature.AddKeys(productWebFeatureId); EdmStructuralProperty productWebFeatureProductId = productWebFeature.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(true)); EdmStructuralProperty productWebFeaturePhotoId = productWebFeature.AddStructuralProperty("PhotoId", EdmCoreModel.Instance.GetInt32(true)); EdmStructuralProperty productWebFeatureReviewId = productWebFeature.AddStructuralProperty("ReviewId", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty productWebFeatureHeading = productWebFeature.AddStructuralProperty("Heading", EdmCoreModel.Instance.GetString(false)); model.AddElement(productWebFeature); EdmEntityType supplier = new EdmEntityType("DefaultNamespace", "Supplier"); EdmStructuralProperty supplierId = supplier.AddStructuralProperty("SupplierId", EdmCoreModel.Instance.GetInt32(false)); supplier.AddKeys(supplierId); EdmStructuralProperty supplierName = supplier.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false)); model.AddElement(supplier); EdmEntityType supplierLogo = new EdmEntityType("DefaultNamespace", "SupplierLogo"); EdmStructuralProperty supplierLogoSupplierId = supplierLogo.AddStructuralProperty("SupplierId", EdmCoreModel.Instance.GetInt32(false)); supplierLogo.AddKeys(supplierLogoSupplierId); EdmStructuralProperty supplierLogoBinary = supplierLogo.AddStructuralProperty("Logo", EdmCoreModel.Instance.GetBinary(false, 500, false)); model.AddElement(supplierLogo); EdmEntityType supplierInfo = new EdmEntityType("DefaultNamespace", "SupplierInfo"); EdmStructuralProperty supplierInfoId = supplierInfo.AddStructuralProperty("SupplierInfoId", EdmCoreModel.Instance.GetInt32(false)); supplierInfo.AddKeys(supplierInfoId); EdmStructuralProperty supplierInfoDescription = supplierInfo.AddStructuralProperty("Information", EdmCoreModel.Instance.GetString(false)); model.AddElement(supplierInfo); EdmEntityType customerInfo = new EdmEntityType("DefaultNamespace", "CustomerInfo"); EdmStructuralProperty customerInfoId = customerInfo.AddStructuralProperty("CustomerInfoId", EdmCoreModel.Instance.GetInt32(false)); customerInfo.AddKeys(customerInfoId); EdmStructuralProperty customerInfoDescription = customerInfo.AddStructuralProperty("Information", EdmCoreModel.Instance.GetString(true)); model.AddElement(customerInfo); EdmEntityType computer = new EdmEntityType("DefaultNamespace", "Computer"); EdmStructuralProperty computerId = computer.AddStructuralProperty("ComputerId", EdmCoreModel.Instance.GetInt32(false)); computer.AddKeys(computerId); EdmStructuralProperty computerName = computer.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false)); model.AddElement(computer); EdmEntityType computerDetail = new EdmEntityType("DefaultNamespace", "ComputerDetail"); EdmStructuralProperty computerDetailId = computerDetail.AddStructuralProperty("ComputerDetailId", EdmCoreModel.Instance.GetInt32(false)); computerDetail.AddKeys(computerDetailId); EdmStructuralProperty computerDetailManufacturer = computerDetail.AddStructuralProperty("Manufacturer", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty computerDetailModel = computerDetail.AddStructuralProperty("Model", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty computerDetailSerial = computerDetail.AddStructuralProperty("Serial", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty computerDetailSpecificationsBag = computerDetail.AddStructuralProperty("SpecificationsBag", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false))); EdmStructuralProperty computerDetailPurchaseDate = computerDetail.AddStructuralProperty("PurchaseDate", EdmCoreModel.Instance.GetDateTimeOffset(false)); EdmStructuralProperty computerDetailDimensions = computerDetail.AddStructuralProperty("Dimensions", new EdmComplexTypeReference(dimensions, false)); model.AddElement(computerDetail); EdmEntityType driver = new EdmEntityType("DefaultNamespace", "Driver"); EdmStructuralProperty driverName = driver.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false, 100, null, false)); driver.AddKeys(driverName); EdmStructuralProperty driverBirthDate = driver.AddStructuralProperty("BirthDate", EdmCoreModel.Instance.GetDateTimeOffset(false)); model.AddElement(driver); EdmEntityType license = new EdmEntityType("DefaultNamespace", "License"); EdmStructuralProperty licenseName = license.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false, 100, null, false)); license.AddKeys(licenseName); EdmStructuralProperty licenseNumber = license.AddStructuralProperty("LicenseNumber", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty licenseClass = license.AddStructuralProperty("LicenseClass", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty licenseRestrictions = license.AddStructuralProperty("Restrictions", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty licenseExpiration = license.AddStructuralProperty("ExpirationDate", EdmCoreModel.Instance.GetDateTimeOffset(false)); model.AddElement(license); EdmEntityType mappedEntity = new EdmEntityType("DefaultNamespace", "MappedEntityType"); EdmStructuralProperty mappedEntityId = mappedEntity.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false)); mappedEntity.AddKeys(mappedEntityId); EdmStructuralProperty mappedEntityHref = mappedEntity.AddStructuralProperty("Href", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty mappedEntityTitle = mappedEntity.AddStructuralProperty("Title", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty mappedEntityHrefLang = mappedEntity.AddStructuralProperty("HrefLang", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty mappedEntityType = mappedEntity.AddStructuralProperty("Type", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty mappedEntityLength = mappedEntity.AddStructuralProperty("Length", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty mappedEntityBagOfPrimitiveToLinks = mappedEntity.AddStructuralProperty("BagOfPrimitiveToLinks", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false))); EdmStructuralProperty mappedEntityBagOfDecimals = mappedEntity.AddStructuralProperty("BagOfDecimals", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetDecimal(false))); EdmStructuralProperty mappedEntityBagOfDoubles = mappedEntity.AddStructuralProperty("BagOfDoubles", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetDouble(false))); EdmStructuralProperty mappedEntityBagOfSingles = mappedEntity.AddStructuralProperty("BagOfSingles", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetSingle(false))); EdmStructuralProperty mappedEntityBagOfBytes = mappedEntity.AddStructuralProperty("BagOfBytes", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetByte(false))); EdmStructuralProperty mappedEntityBagOfInt16s = mappedEntity.AddStructuralProperty("BagOfInt16s", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt16(false))); EdmStructuralProperty mappedEntityBagOfInt32s = mappedEntity.AddStructuralProperty("BagOfInt32s", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt32(false))); EdmStructuralProperty mappedEntityBagOfInt64s = mappedEntity.AddStructuralProperty("BagOfInt64s", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt64(false))); EdmStructuralProperty mappedEntityBagOfGuids = mappedEntity.AddStructuralProperty("BagOfGuids", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetGuid(false))); EdmStructuralProperty mappedEntityBagOfComplexToCategories = mappedEntity.AddStructuralProperty("BagOfComplexToCategories", EdmCoreModel.GetCollection(new EdmComplexTypeReference(category, false))); model.AddElement(mappedEntity); EdmEntityType car = new EdmEntityType("DefaultNamespace", "Car"); EdmStructuralProperty carVin = car.AddStructuralProperty("VIN", EdmCoreModel.Instance.GetInt32(false)); car.AddKeys(carVin); EdmStructuralProperty carDescription = car.AddStructuralProperty("Description", EdmCoreModel.Instance.GetString(false, 100, null, true)); EdmStructuralProperty carPhoto = car.AddStructuralProperty("Photo", EdmCoreModel.Instance.GetStream(false)); EdmStructuralProperty carVideo = car.AddStructuralProperty("Video", EdmCoreModel.Instance.GetStream(false)); model.AddElement(car); EdmEntityType person = new EdmEntityType("DefaultNamespace", "Person"); EdmStructuralProperty personId = person.AddStructuralProperty("PersonId", EdmCoreModel.Instance.GetInt32(false)); person.AddKeys(personId); EdmStructuralProperty personName = person.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false)); model.AddElement(person); EdmEntityType employee = new EdmEntityType("DefaultNamespace", "Employee", person); EdmStructuralProperty employeeManagerId = employee.AddStructuralProperty("ManagersPersonId", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty employeeSalary = employee.AddStructuralProperty("Salary", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty employeeTitle = employee.AddStructuralProperty("Title", EdmCoreModel.Instance.GetString(false)); model.AddElement(employee); EdmEntityType specialEmployee = new EdmEntityType("DefaultNamespace", "SpecialEmployee", employee); EdmStructuralProperty specialEmployeeCarsVIN = specialEmployee.AddStructuralProperty("CarsVIN", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty specialEmployeeBonus = specialEmployee.AddStructuralProperty("Bonus", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty specialEmployeeIsFullyVested = specialEmployee.AddStructuralProperty("IsFullyVested", EdmCoreModel.Instance.GetBoolean(false)); model.AddElement(specialEmployee); EdmEntityType personMetadata = new EdmEntityType("DefaultNamespace", "PersonMetadata"); EdmStructuralProperty personMetadataId = personMetadata.AddStructuralProperty("PersonMetadataId", EdmCoreModel.Instance.GetInt32(false)); personMetadata.AddKeys(personMetadataId); EdmStructuralProperty personMetadataPersonId = personMetadata.AddStructuralProperty("PersonId", EdmCoreModel.Instance.GetInt32(false)); EdmStructuralProperty personMetadataPropertyName = personMetadata.AddStructuralProperty("PropertyName", EdmCoreModel.Instance.GetString(false)); EdmStructuralProperty personMetadataPropertyValue = personMetadata.AddStructuralProperty("PropertyValue", EdmCoreModel.Instance.GetString(false)); model.AddElement(personMetadata); EdmNavigationProperty customerToOrders = customer.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Orders", Target = order, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Customer", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { orderCustomerId }, PrincipalProperties = customer.Key() }); EdmNavigationProperty customerToLogins = customer.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Logins", Target = login, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Customer", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new [] { loginCustomerId }, PrincipalProperties = customer.Key()}); EdmNavigationProperty customerToHusband = customer.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Husband", Target = customer, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }, new EdmNavigationPropertyInfo() { Name = "Wife", TargetMultiplicity = EdmMultiplicity.ZeroOrOne }); EdmNavigationProperty customerToInfo = customer.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Info", Target = customerInfo, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }, new EdmNavigationPropertyInfo() { Name = "Customer", TargetMultiplicity = EdmMultiplicity.One }); EdmNavigationProperty customerToComplaint = customer.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Complaints", Target = complaint, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Customer", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { complaintCustomerId }, PrincipalProperties = customer.Key() }); EdmNavigationProperty barcodeToProduct = barcode.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Product", Target = product, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { barcodeProductId }, PrincipalProperties = product.Key() }, new EdmNavigationPropertyInfo() { Name = "Barcodes", TargetMultiplicity = EdmMultiplicity.Many }); EdmNavigationProperty barcodeToExpectedIncorrectScans = barcode.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "BadScans", Target = incorrectScan, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "ExpectedBarcode", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { incorrectScanExpectedCode }, PrincipalProperties = barcode.Key() }); EdmNavigationProperty barcodeToActualIncorrectScans = barcode.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "GoodScans", Target = incorrectScan, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "ActualBarcode", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { incorrectScanActualCode }, PrincipalProperties = barcode.Key()}); EdmNavigationProperty barcodeToBarcodeDetail = barcode.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Detail", Target = barcodeDetail, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }, new EdmNavigationPropertyInfo() { Name = "Barcode", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { barcodeDetailCode }, PrincipalProperties = barcode.Key()}); EdmNavigationProperty complaintToResolution = complaint.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Resolution", Target = resolution, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }, new EdmNavigationPropertyInfo() { Name = "Complaint", TargetMultiplicity = EdmMultiplicity.One }); EdmNavigationProperty loginToLastLogin = login.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "LastLogin", Target = lastLogin, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }, new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { lastLoginUsername }, PrincipalProperties = login.Key()}); EdmNavigationProperty loginToSentMessages = login.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "SentMessages", Target = message, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Sender", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { messageFromUsername }, PrincipalProperties = login.Key()}); EdmNavigationProperty loginToReceivedMessages = login.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "ReceivedMessages", Target = message, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Recipient", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { messageToUsername }, PrincipalProperties = login.Key()}); EdmNavigationProperty loginToOrders = login.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Orders", Target = order, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.ZeroOrOne }); EdmNavigationProperty loginToSmartCard = login.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "SmartCard", Target = smartCard, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }, new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { smartCardUsername }, PrincipalProperties = login.Key()}); EdmNavigationProperty loginToRsaToken = login.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "RSAToken", Target = rsaToken, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }, new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One }); EdmNavigationProperty loginToPasswordReset = login.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "PasswordResets", Target = passwordReset, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { passwordResetUsername }, PrincipalProperties = login.Key()}); EdmNavigationProperty loginToPageView = login.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "PageViews", Target = pageView, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { pageViewUsername }, PrincipalProperties = login.Key()}); EdmNavigationProperty loginToSuspiciousActivity = login.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "SuspiciousActivity", Target = suspiciousActivity, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.ZeroOrOne }); EdmNavigationProperty smartCardToLastLogin = smartCard.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "LastLogin", Target = lastLogin, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }, new EdmNavigationPropertyInfo() { Name = "SmartCard", TargetMultiplicity = EdmMultiplicity.ZeroOrOne }); EdmNavigationProperty orderToOrderLines = order.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "OrderLines", Target = orderLine, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Order", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderLineOrderId }, PrincipalProperties = order.Key()}); EdmNavigationProperty orderToOrderNotes = EdmNavigationProperty.CreateNavigationPropertyWithPartner( new EdmNavigationPropertyInfo() { Name = "Notes", Target = orderNote, TargetMultiplicity = EdmMultiplicity.Many, OnDelete = EdmOnDeleteAction.Cascade }, new EdmNavigationPropertyInfo() { Name = "Order", Target = order, TargetMultiplicity = EdmMultiplicity.One }); order.AddProperty(orderToOrderNotes); orderNote.AddProperty(orderToOrderNotes.Partner); EdmNavigationProperty orderToOrderQualityCheck = order.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "OrderQualityCheck", Target = orderQualityCheck, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }, new EdmNavigationPropertyInfo() { Name = "Order", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderQualityCheckId }, PrincipalProperties = order.Key()}); EdmNavigationProperty orderLineToProduct = orderLine.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Product", Target = product, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderLineProductId }, PrincipalProperties = product.Key()}, new EdmNavigationPropertyInfo() { Name = "OrderLines", TargetMultiplicity = EdmMultiplicity.Many }); EdmNavigationProperty productToRelatedProducts = product.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "RelatedProducts", Target = product, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "ProductToRelatedProducts", TargetMultiplicity = EdmMultiplicity.One }); EdmNavigationProperty productToSuppliers = product.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Suppliers", Target = supplier, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Products", TargetMultiplicity = EdmMultiplicity.Many }); EdmNavigationProperty productToProductDetail = product.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Detail", Target = productDetail, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }, new EdmNavigationPropertyInfo() { Name = "Product", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productDetailProductId }, PrincipalProperties = product.Key()}); EdmNavigationProperty productToProductReviews = product.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Reviews", Target = productReview, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Product", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productReviewProductId }, PrincipalProperties = product.Key()}); EdmNavigationProperty productToProductPhotos = product.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Photos", Target = productPhoto, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Product", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productPhotoProductId }, PrincipalProperties = product.Key()}); EdmNavigationProperty productReviewToProductWebFeatures = productReview.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Features", Target = productWebFeature, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Review", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { productWebFeatureReviewId, productWebFeatureProductId }, PrincipalProperties = productReview.Key()}); EdmNavigationProperty productPhotoToProductWebFeatures = productPhoto.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Features", Target = productWebFeature, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Photo", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { productWebFeaturePhotoId, productWebFeatureProductId }, PrincipalProperties = productPhoto.Key()}); EdmNavigationProperty supplierToSupplierLogo = supplier.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Logo", Target = supplierLogo, TargetMultiplicity = EdmMultiplicity.ZeroOrOne }, new EdmNavigationPropertyInfo() { Name = "Supplier", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { supplierLogoSupplierId }, PrincipalProperties = supplier.Key()}); EdmNavigationProperty supplierToSupplierInfo = EdmNavigationProperty.CreateNavigationPropertyWithPartner( new EdmNavigationPropertyInfo() { Name = "SupplierInfo", Target = supplierInfo, TargetMultiplicity = EdmMultiplicity.Many, OnDelete = EdmOnDeleteAction.Cascade }, new EdmNavigationPropertyInfo() { Name = "Supplier", Target = supplier, TargetMultiplicity = EdmMultiplicity.One }); supplier.AddProperty(supplierToSupplierInfo); supplierInfo.AddProperty(supplierToSupplierInfo.Partner); EdmNavigationProperty computerToComputerDetail = computer.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "ComputerDetail", Target = computerDetail, TargetMultiplicity = EdmMultiplicity.One }, new EdmNavigationPropertyInfo() { Name = "Computer", TargetMultiplicity = EdmMultiplicity.One }); EdmNavigationProperty driverTolicense = driver.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "License", Target = license, TargetMultiplicity = EdmMultiplicity.One }, new EdmNavigationPropertyInfo() { Name = "Driver", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { licenseName }, PrincipalProperties = driver.Key()}); EdmNavigationProperty personToPersonMetadata = person.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "PersonMetadata", Target = personMetadata, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo() { Name = "Person", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { personMetadataPersonId }, PrincipalProperties = person.Key()}); EdmNavigationProperty employeeToManager = employee.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Manager", Target = employee, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { employeeManagerId }, PrincipalProperties = employee.Key()}, new EdmNavigationPropertyInfo() { Name = "EmployeeToManager", TargetMultiplicity = EdmMultiplicity.Many }); EdmNavigationProperty specialEmployeeToCar = specialEmployee.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "Car", Target = car, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { specialEmployeeCarsVIN }, PrincipalProperties = car.Key()}, new EdmNavigationPropertyInfo() { Name = "SpecialEmployee", TargetMultiplicity = EdmMultiplicity.Many }); EdmOperation getPrimitiveString = new EdmFunction("DefaultNamespace", "GetPrimitiveString", EdmCoreModel.Instance.GetString(true)); model.AddElement(getPrimitiveString); EdmOperation getSpecificCustomer = new EdmFunction("DefaultNamespace", "GetSpecificCustomer", EdmCoreModel.GetCollection(new EdmEntityTypeReference(customer, true))); getSpecificCustomer.AddParameter("Name", EdmCoreModel.Instance.GetString(false)); model.AddElement(getSpecificCustomer); EdmOperation getCustomerCount = new EdmFunction("DefaultNamespace", "GetCustomerCount", EdmCoreModel.Instance.GetInt32(true)); model.AddElement(getCustomerCount); EdmOperation getArgumentPlusOne = new EdmFunction("DefaultNamespace", "GetArgumentPlusOne", EdmCoreModel.Instance.GetInt32(true)); getArgumentPlusOne.AddParameter("arg1", EdmCoreModel.Instance.GetInt32(false)); model.AddElement(getArgumentPlusOne); EdmOperation entityProjectionReturnsCollectionOfComplexTypes = new EdmFunction("DefaultNamespace", "EntityProjectionReturnsCollectionOfComplexTypes", EdmCoreModel.GetCollection(new EdmComplexTypeReference(contact, true))); model.AddElement(entityProjectionReturnsCollectionOfComplexTypes); EdmOperation setArgumentPlusOne = new EdmAction("DefaultNamespace", "SetArgumentPlusOne", EdmCoreModel.Instance.GetInt32(true)); setArgumentPlusOne.AddParameter("arg1", EdmCoreModel.Instance.GetInt32(false)); model.AddElement(setArgumentPlusOne); EdmEntityContainer container = new EdmEntityContainer("DefaultNamespace", "DefaultContainer"); model.AddElement(container); EdmEntitySet carSet = container.AddEntitySet("Car", car); EdmEntitySet customerSet = container.AddEntitySet("Customer", customer); EdmEntitySet barcodeSet = container.AddEntitySet("Barcode", barcode); EdmEntitySet incorrectScanSet = container.AddEntitySet("IncorrectScan", incorrectScan); EdmEntitySet barcodeDetailSet = container.AddEntitySet("BarcodeDetail", barcodeDetail); EdmEntitySet complaintSet = container.AddEntitySet("Complaint", complaint); EdmEntitySet resolutionSet = container.AddEntitySet("Resolution", resolution); EdmEntitySet loginSet = container.AddEntitySet("Login", login); EdmEntitySet suspiciousActivitySet = container.AddEntitySet("SuspiciousActivity", suspiciousActivity); EdmEntitySet smartCardSet = container.AddEntitySet("SmartCard", smartCard); EdmEntitySet rsaTokenSet = container.AddEntitySet("RSAToken", rsaToken); EdmEntitySet passwordResetSet = container.AddEntitySet("PasswordReset", passwordReset); EdmEntitySet pageViewSet = container.AddEntitySet("PageView", pageView); EdmEntitySet lastLoginSet = container.AddEntitySet("LastLogin", lastLogin); EdmEntitySet messageSet = container.AddEntitySet("Message", message); EdmEntitySet orderSet = container.AddEntitySet("Order", order); EdmEntitySet orderNoteSet = container.AddEntitySet("OrderNote", orderNote); EdmEntitySet orderQualityCheckSet = container.AddEntitySet("OrderQualityCheck", orderQualityCheck); EdmEntitySet orderLineSet = container.AddEntitySet("OrderLine", orderLine); EdmEntitySet productSet = container.AddEntitySet("Product", product); EdmEntitySet productDetailSet = container.AddEntitySet("ProductDetail", productDetail); EdmEntitySet productReviewSet = container.AddEntitySet("ProductReview", productReview); EdmEntitySet productPhotoSet = container.AddEntitySet("ProductPhoto", productPhoto); EdmEntitySet productWebFeatureSet = container.AddEntitySet("ProductWebFeature", productWebFeature); EdmEntitySet supplierSet = container.AddEntitySet("Supplier", supplier); EdmEntitySet supplierLogoSet = container.AddEntitySet("SupplierLogo", supplierLogo); EdmEntitySet supplierInfoSet = container.AddEntitySet("SupplierInfo", supplierInfo); EdmEntitySet customerInfoSet = container.AddEntitySet("CustomerInfo", customerInfo); EdmEntitySet computerSet = container.AddEntitySet("Computer", computer); EdmEntitySet computerDetailSet = container.AddEntitySet("ComputerDetail", computerDetail); EdmEntitySet driverSet = container.AddEntitySet("Driver", driver); EdmEntitySet licenseSet = container.AddEntitySet("License", license); EdmEntitySet mappedEntitySet = container.AddEntitySet("MappedEntityType", mappedEntity); EdmEntitySet personSet = container.AddEntitySet("Person", person); EdmEntitySet personMetadataSet = container.AddEntitySet("PersonMetadata", personMetadata); complaintSet.AddNavigationTarget(customerToComplaint.Partner, customerSet); loginSet.AddNavigationTarget(loginToSentMessages, messageSet); loginSet.AddNavigationTarget(loginToReceivedMessages, messageSet); customerInfoSet.AddNavigationTarget(customerToInfo.Partner, customerSet); supplierSet.AddNavigationTarget(supplierToSupplierInfo, supplierInfoSet); loginSet.AddNavigationTarget(loginToOrders, orderSet); orderSet.AddNavigationTarget(orderToOrderNotes, orderNoteSet); orderSet.AddNavigationTarget(orderToOrderQualityCheck, orderQualityCheckSet); supplierSet.AddNavigationTarget(supplierToSupplierLogo, supplierLogoSet); customerSet.AddNavigationTarget(customerToOrders, orderSet); customerSet.AddNavigationTarget(customerToLogins, loginSet); loginSet.AddNavigationTarget(loginToLastLogin, lastLoginSet); lastLoginSet.AddNavigationTarget(smartCardToLastLogin.Partner, smartCardSet); orderSet.AddNavigationTarget(orderToOrderLines, orderLineSet); productSet.AddNavigationTarget(orderLineToProduct.Partner, orderLineSet); productSet.AddNavigationTarget(productToRelatedProducts, productSet); productSet.AddNavigationTarget(productToProductDetail, productDetailSet); productSet.AddNavigationTarget(productToProductReviews, productReviewSet); productSet.AddNavigationTarget(productToProductPhotos, productPhotoSet); productWebFeatureSet.AddNavigationTarget(productPhotoToProductWebFeatures.Partner, productPhotoSet); productWebFeatureSet.AddNavigationTarget(productReviewToProductWebFeatures.Partner, productReviewSet); complaintSet.AddNavigationTarget(complaintToResolution, resolutionSet); barcodeSet.AddNavigationTarget(barcodeToExpectedIncorrectScans, incorrectScanSet); customerSet.AddNavigationTarget(customerToHusband.Partner, customerSet); barcodeSet.AddNavigationTarget(barcodeToActualIncorrectScans, incorrectScanSet); productSet.AddNavigationTarget(barcodeToProduct.Partner, barcodeSet); barcodeSet.AddNavigationTarget(barcodeToBarcodeDetail, barcodeDetailSet); loginSet.AddNavigationTarget(loginToSuspiciousActivity, suspiciousActivitySet); loginSet.AddNavigationTarget(loginToRsaToken, rsaTokenSet); loginSet.AddNavigationTarget(loginToSmartCard, smartCardSet); loginSet.AddNavigationTarget(loginToPasswordReset, passwordResetSet); loginSet.AddNavigationTarget(loginToPageView, pageViewSet); computerSet.AddNavigationTarget(computerToComputerDetail, computerDetailSet); driverSet.AddNavigationTarget(driverTolicense, licenseSet); personSet.AddNavigationTarget(personToPersonMetadata, personMetadataSet); productSet.AddNavigationTarget(productToSuppliers, supplierSet); carSet.AddNavigationTarget(specialEmployeeToCar.Partner, personSet); personSet.AddNavigationTarget(employeeToManager, personSet); this.BasicConstructibleModelTestSerializingStockModel(ODataTestModelBuilder.ODataTestModelDefaultModel, model); }
public void DollarMetadata_Works_WithMultipleReferentialConstraints_ForUntypeModel() { // Arrange EdmModel model = new EdmModel(); EdmEntityType customer = new EdmEntityType("DefaultNamespace", "Customer"); customer.AddKeys(customer.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(isNullable: false))); customer.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(isUnbounded: false, maxLength: 100, isUnicode: null, isNullable: false)); model.AddElement(customer); EdmEntityType order = new EdmEntityType("DefaultNamespace", "Order"); order.AddKeys(order.AddStructuralProperty("OrderId", EdmCoreModel.Instance.GetInt32(false))); EdmStructuralProperty orderCustomerId = order.AddStructuralProperty("CustomerForeignKey", EdmCoreModel.Instance.GetInt32(true)); model.AddElement(order); customer.AddBidirectionalNavigation( new EdmNavigationPropertyInfo { Name = "Orders", Target = order, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo { Name = "Customer", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { orderCustomerId }, PrincipalProperties = customer.Key() }); const string expect = " <Property Name=\"CustomerForeignKey\" Type=\"Edm.Int32\" />\r\n" + " <NavigationProperty Name=\"Customer\" Type=\"DefaultNamespace.Customer\" Partner=\"Orders\">\r\n" + " <ReferentialConstraint Property=\"CustomerForeignKey\" ReferencedProperty=\"CustomerId\" />\r\n" + " </NavigationProperty>"; HttpConfiguration config = new[] { typeof(MetadataController) }.GetHttpConfiguration(); HttpServer server = new HttpServer(config); config.MapODataServiceRoute("odata", "odata", model); HttpClient client = new HttpClient(server); // Act HttpResponseMessage response = client.GetAsync("http://localhost/odata/$metadata").Result; // Assert Assert.True(response.IsSuccessStatusCode); Assert.Equal("application/xml", response.Content.Headers.ContentType.MediaType); Assert.Contains(expect, response.Content.ReadAsStringAsync().Result); }
public static IEdmModel ModelWithReferentialConstraintWhoseDependentPropertiesNotPartOfDependentEntity() { EdmModel model = new EdmModel(); var entity1 = new EdmEntityType("Foo", "Bar"); var id1 = new EdmStructuralProperty(entity1, "Id", EdmCoreModel.Instance.GetInt16(false), null, EdmConcurrencyMode.None); entity1.AddKeys(id1); var entity2 = new EdmEntityType("Foo", "Baz"); var id2 = new EdmStructuralProperty(entity2, "Id", EdmCoreModel.Instance.GetInt16(false), null, EdmConcurrencyMode.None); entity2.AddKeys(id2); StubEdmNavigationProperty navProp1 = new StubEdmNavigationProperty("ToBaz"); StubEdmNavigationProperty navProp2 = new StubEdmNavigationProperty("ToBar"); navProp1.Type = new EdmEntityTypeReference(entity2, false); navProp1.DeclaringType = entity1; navProp1.ReferentialConstraint = EdmReferentialConstraint.Create(new[] { new EdmStructuralProperty(entity2, "Id1", EdmCoreModel.Instance.GetInt16(false), null, EdmConcurrencyMode.None) }, entity2.Key()); navProp1.Partner = navProp2; navProp2.Type = new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(entity1, false))); navProp2.DeclaringType = entity2; navProp2.Partner = navProp1; entity1.AddProperty(navProp1); entity2.AddProperty(navProp2); model.AddElement(entity1); model.AddElement(entity2); return model; }
public static IEdmModel ModelWithInvalidDependentProperties() { EdmModel model = new EdmModel(); var entity1 = new EdmEntityType("Foo", "Bar"); var id1 = new EdmStructuralProperty(entity1, "Id", EdmCoreModel.Instance.GetInt16(false), null, EdmConcurrencyMode.None); entity1.AddKeys(id1); var entity2 = new EdmEntityType("Foo", "Baz"); var id2 = new EdmStructuralProperty(entity2, "Id", EdmCoreModel.Instance.GetInt16(false), null, EdmConcurrencyMode.None); entity2.AddKeys(id2); EdmNavigationProperty entity1Navigation = entity1.AddBidirectionalNavigation( new EdmNavigationPropertyInfo() { Name = "ToBaz", Target = entity2, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { id2 }, PrincipalProperties = entity2.Key() }, new EdmNavigationPropertyInfo() { Name = "ToBar", TargetMultiplicity = EdmMultiplicity.Many }); model.AddElement(entity1); return model; }