├── .gitattributes ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── ISSUE_TRIAGE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── README.md ├── SECURITY.md ├── build ├── GetNugetPackageMetadata.proj ├── azure-pipelines-nightly.yml ├── azure-pipelines-rolling.yml ├── build.props ├── build.targets └── builder.versions.settings.targets ├── images └── odata.png ├── sln └── OData.ModelBuilder.sln ├── src └── Microsoft.OData.ModelBuilder │ ├── Annotations │ ├── ClrEnumMemberAnnotation.cs │ ├── ClrPropertyInfoAnnotation.cs │ ├── ClrTypeAnnotation.cs │ ├── ConcurrencyPropertiesAnnotation.cs │ ├── DynamicPropertyDictionaryAnnotation.cs │ ├── EdmAnnotationExtensions.cs │ ├── InstanceAnnotationContainerAnnotation.cs │ ├── NavigationSourceLinkBuilderAnnotation.cs │ ├── OperationTitleAnnotation.cs │ ├── QueryableRestrictionsAnnotation.cs │ └── ReturnedEntitySetAnnotation.cs │ ├── Attributes │ ├── ActionOnDeleteAttribute.cs │ ├── AutoExpandAttribute.cs │ ├── ContainedAttribute.cs │ ├── CountAttribute.cs │ ├── ExpandAttribute.cs │ ├── FilterCountAttribute.cs │ ├── MediaTypeAttribute.cs │ ├── NonFilterableAttribute.cs │ ├── NotCountableAttribute.cs │ ├── NotExpandableAttribute.cs │ ├── NotFilterableAttribute.cs │ ├── NotNavigableAttribute.cs │ ├── NotSortableAttribute.cs │ ├── OrderByAttribute.cs │ ├── PageAttribute.cs │ ├── SelectAttribute.cs │ ├── SelectExpandType.cs │ ├── SingletonAttribute.cs │ └── UnsortableAttribute.cs │ ├── Commons │ ├── EdmLibHelpers.cs │ ├── Error.cs │ ├── PropertyPairSelectorVisitor.cs │ ├── PropertySelectorVisitor.cs │ └── TypeHelper.cs │ ├── Config │ ├── DefaultQuerySettings.cs │ ├── ExpandConfiguration.cs │ ├── ModelBoundQuerySettings.cs │ ├── QueryConfiguration.cs │ └── QueryableRestrictions.cs │ ├── Containers │ ├── BindingPathConfigurationOfTStructuralType.cs │ ├── BindingPathHelper.cs │ ├── EntitySetConfiguration.cs │ ├── EntitySetConfigurationOfTEntityType.cs │ ├── IODataInstanceAnnotationContainer.cs │ ├── IODataInstanceAnnotationContainerExtensions.cs │ ├── NavigationPropertyBindingConfiguration.cs │ ├── NavigationPropertyBindingOption.cs │ ├── NavigationSourceConfiguration.cs │ ├── NavigationSourceConfigurationOfTEntityType.cs │ ├── ODataInstanceAnnotationContainer.cs │ ├── SingletonConfiguration.cs │ └── SingletonConfigurationOfTEntityType.cs │ ├── Conventions │ ├── AbstractTypeDiscoveryConvention.cs │ ├── ActionLinkGenerationConvention.cs │ ├── AssociationSetDiscoveryConvention.cs │ ├── Attributes │ │ ├── ActionOnDeleteAttributeConvention.cs │ │ ├── AttributeConvention.cs │ │ ├── AttributeEdmPropertyConvention.cs │ │ ├── AttributeEdmTypeConvention.cs │ │ ├── AutoExpandAttributeEdmPropertyConvention.cs │ │ ├── AutoExpandAttributeEdmTypeConvention.cs │ │ ├── ColumnAttributeEdmPropertyConvention.cs │ │ ├── ComplexTypeAttributeConvention.cs │ │ ├── ConcurrencyCheckAttributeEdmPropertyConvention.cs │ │ ├── CountAttributeEdmPropertyConvention.cs │ │ ├── CountAttributeEdmTypeConvention.cs │ │ ├── DataContractAttributeEdmTypeConvention.cs │ │ ├── DataContractAttributeEnumTypeConvention.cs │ │ ├── DataMemberAttributeEdmPropertyConvention.cs │ │ ├── DefaultValueAttributeEdmPropertyConvention.cs │ │ ├── ExpandAttributeEdmPropertyConvention.cs │ │ ├── ExpandAttributeEdmTypeConvention.cs │ │ ├── FilterAttributeEdmPropertyConvention.cs │ │ ├── FilterAttributeEdmTypeConvention.cs │ │ ├── ForeignKeyAttributeConvention.cs │ │ ├── IgnoreDataMemberAttributeEdmPropertyConvention.cs │ │ ├── KeyAttributeEdmPropertyConvention.cs │ │ ├── MaxLengthAttributeEdmPropertyConvention.cs │ │ ├── MediaTypeAttributeConvention.cs │ │ ├── NonFilterableAttributeEdmPropertyConvention.cs │ │ ├── NotCountableAttributeEdmPropertyConvention.cs │ │ ├── NotExpandableAttributeEdmPropertyConvention.cs │ │ ├── NotFilterableAttributeEdmPropertyConvention.cs │ │ ├── NotMappedAttributeEdmPropertyConvention.cs │ │ ├── NotNavigableAttributeEdmPropertyConvention.cs │ │ ├── NotSortableAttributeEdmPropertyConvention.cs │ │ ├── NullableAttributeEdmPropertyConvention.cs │ │ ├── NullableContextAttributeEdmTypeConvention.cs │ │ ├── OrderByAttributeEdmPropertyConvention.cs │ │ ├── OrderByAttributeEdmTypeConvention.cs │ │ ├── PageAttributeEdmPropertyConvention.cs │ │ ├── PageAttributeEdmTypeConvention.cs │ │ ├── PropertyAttributeConvention.cs │ │ ├── RequiredAttributeEdmPropertyConvention.cs │ │ ├── SelectAttributeEdmPropertyConvention.cs │ │ ├── SelectAttributeEdmTypeConvention.cs │ │ ├── TimestampAttributeEdmPropertyConvention.cs │ │ ├── TypeAttributeConvention.cs │ │ └── UnsortableAttributeEdmPropertyConvention.cs │ ├── EntityKeyConvention.cs │ ├── EntityTypeConvention.cs │ ├── ForeignKeyDiscoveryConvention.cs │ ├── FunctionLinkGenerationConvention.cs │ ├── IEdmPropertyConvention.cs │ ├── IEdmPropertyConventionOfTPropertyConfiguration.cs │ ├── IEdmTypeConvention.cs │ ├── INavigationSourceConvention.cs │ ├── IODataModelConvention.cs │ ├── IODataModelConventionSetBuilder.cs │ ├── IOperationConvention.cs │ ├── NavigationLinksGenerationConvention.cs │ ├── ODataModelConventionSet.cs │ └── SelfLinksGenerationConvention.cs │ ├── Helpers │ ├── AssemblyInfo.cs │ ├── BindableOperationFinder.cs │ ├── ConventionsHelpers.cs │ ├── DefaultAssemblyResolver.cs │ ├── EdmModelExtensions.cs │ ├── EdmModelHelperMethods.cs │ ├── EdmTypeBuilder.cs │ ├── EdmTypeMap.cs │ ├── IAssemblyResolver.cs │ ├── NavigationSourceAndAnnotations.cs │ └── NavigationSourceUrlAnnotation.cs │ ├── LowerCamelCaser.cs │ ├── Microsoft.OData.ModelBuilder.Nightly.nuspec │ ├── Microsoft.OData.ModelBuilder.Release.nuspec │ ├── Microsoft.OData.ModelBuilder.csproj │ ├── Microsoft.OData.ModelBuilder.xml │ ├── NameResolverOptions.cs │ ├── ODataContext.cs │ ├── ODataConventionModelBuilder.cs │ ├── ODataConventionModelBuilderExtensions.cs │ ├── ODataModelBuilder.cs │ ├── Operations │ ├── ActionConfiguration.cs │ ├── BindingParameterConfiguration.cs │ ├── FunctionConfiguration.cs │ ├── NonbindingParameterConfiguration.cs │ ├── OperationConfiguration.cs │ ├── OperationKind.cs │ └── ParameterConfiguration.cs │ ├── Property │ ├── CollectionPropertyConfiguration.cs │ ├── ComplexPropertyConfiguration.cs │ ├── DecimalPropertyConfiguration.cs │ ├── EnumPropertyConfiguration.cs │ ├── LengthPropertyConfiguration.cs │ ├── NavigationPropertyConfiguration.cs │ ├── NavigationPropertyExtensions.cs │ ├── PrecisionPropertyConfiguration.cs │ ├── PrimitivePropertyConfiguration.cs │ ├── PrimitivePropertyConfigurationExtensions.cs │ ├── PropertyConfiguration.cs │ ├── PropertyConfigurationExtensions.cs │ ├── PropertyKind.cs │ ├── StructuralPropertyConfiguration.cs │ └── UntypedPropertyConfiguration.cs │ ├── SRResources.Designer.cs │ ├── SRResources.resx │ ├── Types │ ├── CollectionTypeConfiguration.cs │ ├── ComplexTypeConfiguration.cs │ ├── ComplexTypeConfigurationOfTComplexType.cs │ ├── EdmTypeConfigurationExtensions.cs │ ├── EntityCollectionConfigurationOfTEntityType.cs │ ├── EntityTypeConfiguration.cs │ ├── EntityTypeConfigurationOfTEntityType.cs │ ├── EnumMemberConfiguration.cs │ ├── EnumTypeConfiguration.cs │ ├── EnumTypeConfigurationOfTEnumType.cs │ ├── IEdmTypeConfiguration.cs │ ├── NullableEnumTypeConfiguration.cs │ ├── PrimitiveTypeConfiguration.cs │ ├── StructuralTypeConfiguration.cs │ └── StructuralTypeConfigurationOfTStructuralType.cs │ └── Vocabularies │ ├── Capabilities │ └── V1 │ │ ├── AcceptableEncodingsConfiguration.cs │ │ ├── AnnotationValuesInQuerySupportedConfiguration.cs │ │ ├── AsynchronousRequestsSupportedConfiguration.cs │ │ ├── BatchContinueOnErrorSupportedConfiguration.cs │ │ ├── BatchSupportConfiguration.cs │ │ ├── BatchSupportedConfiguration.cs │ │ ├── CallbackProtocolConfiguration.cs │ │ ├── CallbackSupportedConfiguration.cs │ │ ├── ChangeTrackingConfiguration.cs │ │ ├── CollectionPropertyRestrictionsConfiguration.cs │ │ ├── CollectionPropertyRestrictionsTypeConfiguration.cs │ │ ├── ComputeSupportedConfiguration.cs │ │ ├── ConformanceLevelConfiguration.cs │ │ ├── ConformanceLevelType.cs │ │ ├── CountRestrictionsConfiguration.cs │ │ ├── CrossJoinSupportedConfiguration.cs │ │ ├── CustomHeadersConfiguration.cs │ │ ├── CustomParameterConfiguration.cs │ │ ├── CustomQueryOptionsConfiguration.cs │ │ ├── DeepInsertSupportConfiguration.cs │ │ ├── DeepUpdateSupportConfiguration.cs │ │ ├── DeleteRestrictionsConfiguration.cs │ │ ├── ExpandRestrictionsConfiguration.cs │ │ ├── FilterExpressionRestrictionTypeConfiguration.cs │ │ ├── FilterFunctionsConfiguration.cs │ │ ├── FilterRestrictionsConfiguration.cs │ │ ├── HttpMethod.cs │ │ ├── IndexableByKeyConfiguration.cs │ │ ├── InsertRestrictionsConfiguration.cs │ │ ├── IsolationLevel.cs │ │ ├── IsolationSupportedConfiguration.cs │ │ ├── KeyAsSegmentSupportedConfiguration.cs │ │ ├── MediaLocationUpdateSupportedConfiguration.cs │ │ ├── ModificationQueryOptionsConfiguration.cs │ │ ├── NavigationPropertyRestrictionConfiguration.cs │ │ ├── NavigationRestrictionsConfiguration.cs │ │ ├── NavigationType.cs │ │ ├── OperationRestrictionsConfiguration.cs │ │ ├── PermissionTypeConfiguration.cs │ │ ├── QuerySegmentSupportedConfiguration.cs │ │ ├── ReadByKeyRestrictionsTypeConfiguration.cs │ │ ├── ReadRestrictionsConfiguration.cs │ │ ├── ScopeTypeConfiguration.cs │ │ ├── SearchExpressions.cs │ │ ├── SearchRestrictionsConfiguration.cs │ │ ├── SelectSupportConfiguration.cs │ │ ├── SkipSupportedConfiguration.cs │ │ ├── SortRestrictionsConfiguration.cs │ │ ├── SupportedFormatsConfiguration.cs │ │ ├── SupportedMetadataFormatsConfiguration.cs │ │ ├── TopSupportedConfiguration.cs │ │ └── UpdateRestrictionsConfiguration.cs │ ├── CapabilitiesNavigationType.cs │ ├── CapabilitiesVocabularyConstants.cs │ ├── CapabilitiesVocabularyExtensionMethods.cs │ ├── Core │ └── V1 │ │ ├── AcceptableMediaTypesConfiguration.cs │ │ ├── AdditionalPropertiesConfiguration.cs │ │ ├── AlternateKeyConfiguration.cs │ │ ├── AlternateKeysConfiguration.cs │ │ ├── AutoExpandConfiguration.cs │ │ ├── AutoExpandReferencesConfiguration.cs │ │ ├── ComputedConfiguration.cs │ │ ├── ComputedDefaultValueConfiguration.cs │ │ ├── ContentIDConfiguration.cs │ │ ├── ConventionalIDsConfiguration.cs │ │ ├── DataModificationExceptionConfiguration.cs │ │ ├── DataModificationOperationKind.cs │ │ ├── DefaultNamespaceConfiguration.cs │ │ ├── DereferenceableIDsConfiguration.cs │ │ ├── DescriptionConfiguration.cs │ │ ├── ExampleConfiguration.cs │ │ ├── ImmutableConfiguration.cs │ │ ├── IsLanguageDependentConfiguration.cs │ │ ├── IsMediaTypeConfiguration.cs │ │ ├── IsURLConfiguration.cs │ │ ├── LinkConfiguration.cs │ │ ├── LinksConfiguration.cs │ │ ├── LongDescriptionConfiguration.cs │ │ ├── MayImplementConfiguration.cs │ │ ├── MediaTypeConfiguration.cs │ │ ├── MessageTypeConfiguration.cs │ │ ├── MessagesConfiguration.cs │ │ ├── ODataVersionsConfiguration.cs │ │ ├── OperationAvailableConfiguration.cs │ │ ├── OptimisticConcurrencyConfiguration.cs │ │ ├── OptionalParameterConfiguration.cs │ │ ├── OrderedConfiguration.cs │ │ ├── Permission.cs │ │ ├── PermissionsConfiguration.cs │ │ ├── PositionalInsertConfiguration.cs │ │ ├── PrimitiveExampleValueConfiguration.cs │ │ ├── PropertyRefConfiguration.cs │ │ ├── RequiresTypeConfiguration.cs │ │ ├── ResourceExceptionConfiguration.cs │ │ ├── ResourcePathConfiguration.cs │ │ ├── RevisionKind.cs │ │ ├── RevisionTypeConfiguration.cs │ │ ├── RevisionsConfiguration.cs │ │ ├── SchemaVersionConfiguration.cs │ │ └── ValueExceptionConfiguration.cs │ ├── IRecord.cs │ ├── IVocabularyTermConfiguration.cs │ ├── VocabularyConfigurationsBase.cs │ ├── VocabularyTermConfiguration.cs │ ├── VocabularyTermConfigurationExtensions.cs │ ├── VocabularyTermConfigurationExtensions.tt │ └── VocabularyTermConfigurationShortcutsExtensions.cs ├── test └── Microsoft.OData.ModelBuilder.Tests │ ├── Annotations │ ├── ClrPropertyInfoAnnotationTest.cs │ └── DynamicPropertyDictionaryAnnotationTest.cs │ ├── Commons │ ├── CsdlSerializer.cs │ ├── CultureReplacer.cs │ ├── EdmModelAsserts.cs │ ├── ExceptionAssert.cs │ ├── MockAssembly.cs │ ├── MockAssemblyResolver.cs │ ├── MockPropertyInfo.cs │ ├── MockType.cs │ ├── ODataConventionModelBuilderFactory.cs │ ├── ODataModelBuilderExtensions.cs │ ├── ODataModelBuilderMocks.cs │ ├── PropertyPairSelectorVisitorTest.cs │ ├── PropertySelectorVisitorTest.cs │ ├── ReflectionAssert.cs │ ├── TheoryDataSet.cs │ └── TypeHelperTest.cs │ ├── Containers │ ├── BindingCustomerModel.cs │ ├── BindingPathConfigurationOfTStructuralTypeTest.cs │ ├── BindingPathHelperTest.cs │ ├── EntitySetConfigurationTest.cs │ ├── EntitySetTest.cs │ ├── SingletonConfigurationTest.cs │ └── SingletonTest.cs │ ├── Conventions │ ├── AssociationSetDiscoveryConventionTest.cs │ ├── Attributes │ │ ├── ActionOnDeleteAttributeConventionTest.cs │ │ ├── AttributeConventionTests.cs │ │ ├── AttributeEdmPropertyConventionTests.cs │ │ ├── AttributeEdmTypeConventionTests.cs │ │ ├── ColumnAttributeEdmPropertyConventionTest.cs │ │ ├── ComplexTypeAttributeConventionTests.cs │ │ ├── ConcurrencyCheckAttributeEdmPropertyConventionTest.cs │ │ ├── DataContractAttributeEdmTypeConventionTests.cs │ │ ├── DataMemberAttributeEdmPropertyConventionTest.cs │ │ ├── DefaultValueAttributeEdmPropertyConventionTests.cs │ │ ├── ForeignKeyAttributeConventionTest.cs │ │ ├── IgnoreDataMemberAttributeEdmPropertyConventionTests.cs │ │ ├── KeyAttributeEdmPropertyConventionTests.cs │ │ ├── NotMappedAttributeConventionTests.cs │ │ ├── NullableAttributeEdmPropertyConventionTests.cs │ │ ├── RequiredAttributeEdmPropertyConventionTests.cs │ │ └── TimestampAttributeEdmPropertyConventionTests.cs │ ├── EntityKeyConventionTests.cs │ └── ForeignKeyDiscoveryConventionTest.cs │ ├── CsdlMetadataTest.cs │ ├── Helpers │ ├── BindableOperationFinderAnnotationTest.cs │ └── EdmModelExtensionsTest.cs │ ├── LowerCamelCaserTest.cs │ ├── Microsoft.OData.ModelBuilder.Tests.csproj │ ├── ODataConventionModelBuilderTest.cs │ ├── ODataModelBuilderTest.cs │ ├── Operations │ ├── ActionConfigurationTest.cs │ ├── BindingParameterConfigurationTest.cs │ ├── FunctionConfigurationTest.cs │ └── ParameterConfigurationTest.cs │ ├── Property │ ├── CollectionPropertyConfigurationTest.cs │ ├── NavigationPropertyConfigurationTest.cs │ ├── PropertyConfigurationTest.cs │ └── UntypedPropertyConfigurationTest.cs │ ├── PublicApi │ ├── Microsoft.OData.ModelBuilder.PublicApi.bsl │ ├── PublicApiHelper.cs │ └── PublicApiTest.cs │ ├── Scenarios │ └── UntypedTest.cs │ ├── TestModels │ ├── Address.cs │ ├── Client.cs │ ├── Color.cs │ ├── Company.cs │ ├── Customer.cs │ ├── DateTimeModel.cs │ ├── Employee.cs │ ├── EnumModels.cs │ ├── Gift.cs │ ├── INameAndIdContainer.cs │ ├── InheritanceModels.cs │ ├── ModelAlias.cs │ ├── MyOrder.cs │ ├── MySpecialOrder.cs │ ├── NonNullable │ │ ├── Address.cs │ │ ├── Company.cs │ │ ├── Customer.cs │ │ ├── Employee.cs │ │ ├── Order.cs │ │ └── ZipCode.cs │ ├── ODataModelBuilderExtensions.cs │ ├── Order.cs │ ├── OrderCancellation.cs │ ├── OrderHeader.cs │ ├── OrderLine.cs │ ├── RecursiveModel.cs │ ├── SpecialOrderLine.cs │ ├── WorkItem.cs │ └── ZipCode.cs │ ├── Types │ ├── ComplexTypeConfigurationTest.cs │ ├── ComplexTypeTest.cs │ ├── EdmTypeConfigurationExtensionsTest.cs │ ├── EntityTypeTest.cs │ ├── EnumTypeTest.cs │ ├── PrimitiveTypeTest.cs │ ├── RecursiveComplexTypesModels.cs │ ├── RecursiveComplexTypesTest.cs │ ├── StructuralTypeConfigurationOfTStructuralTypeTest.cs │ └── StructuralTypeConfigurationTest.cs │ └── Vocabularies │ ├── Capabilities │ ├── DeleteRestrictionsConfigurationTests.cs │ └── OperationRestrictionsConfigurationTests.cs │ └── Core │ └── RevisionsConfigurationTests.cs └── tools └── 35MSSharedLib1024.snk /.gitattributes: -------------------------------------------------------------------------------- 1 | * text 2 | 3 | *.bmp binary 4 | *.dll binary 5 | *.gif binary 6 | *.jpg binary 7 | *.png binary 8 | *.snk binary 9 | *.mdf binary 10 | *.ldf binary 11 | *.sql binary 12 | *.nupkg binary 13 | *.exe binary 14 | 15 | *.ascx text 16 | *.cd text 17 | *.cmd text 18 | *.coffee text 19 | *.config text 20 | *.cs text diff=csharp 21 | *.csproj text merge=union 22 | *.cshtml text 23 | *.css text 24 | *.dtd text 25 | *.edmx text 26 | *.htm text 27 | *.html text 28 | *.js text 29 | *.json text 30 | *.msbuild text 31 | *.nuspec text 32 | *.resx text 33 | *.ruleset text 34 | *.StyleCop text 35 | *.targets text 36 | *.tt text 37 | *.txt text 38 | *.vb text 39 | *.vbhtml text 40 | *.vbproj text merge=union 41 | *.vbs text 42 | *.wsf text 43 | *.xml text 44 | *.xunit text 45 | 46 | *.sln text eol=crlf merge=union 47 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | *Short summary (3-5 sentences) describing the issue.* 4 | 5 | ### Assemblies affected 6 | 7 | *Which assemblies and versions are known to be affected e.g. OData ModelBuilder 1.x* 8 | 9 | ### Reproduce steps 10 | 11 | *The simplest set of steps to reproduce the issue. If possible, reference a commit that demonstrates the issue.* 12 | 13 | ### Expected result 14 | 15 | *What would happen if there wasn't a bug.* 16 | 17 | ### Actual result 18 | 19 | *What is actually happening.* 20 | 21 | ### Additional detail 22 | 23 | *Optional, details of the root cause if known. Delete this section if you have no additional details to add.* 24 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### Issues 4 | 5 | *This pull request fixes issue #xxx.* 6 | 7 | ### Description 8 | 9 | *Briefly describe the changes of this pull request.* 10 | 11 | ### Checklist (Uncheck if it is not completed) 12 | 13 | - [ ] *Test cases added* 14 | - [ ] *Build and test with one-click build and test script passed* 15 | 16 | ### Additional work necessary 17 | 18 | *If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.* 19 | -------------------------------------------------------------------------------- /build/GetNugetPackageMetadata.proj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $([System.DateTime]::Now.ToString("yyyyMMddHHmm")) 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /build/build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | $(WebStackRootPath)bin\$(Configuration)\ 6 | AnyCPU 7 | 8 | 9 | ENU 10 | 11 | 12 | 13 | true 14 | true 15 | $(MSBuildThisFileFullPath)\..\..\tools\35MSSharedLib1024.snk 16 | 17 | $(MSBuildThisFileDirectory) 18 | 19 | 21 | $(ModelBuildPath)build.targets 22 | 23 | 24 | 25 | true 26 | full 27 | false 28 | TRACE;DEBUG 29 | 30 | 31 | portable 32 | true 33 | TRACE 34 | 35 | -------------------------------------------------------------------------------- /build/build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /images/odata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OData/ModelBuilder/f3e39bcf3320aacf9cc475caa39a1fc9156da125/images/odata.png -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Annotations/ClrPropertyInfoAnnotation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Reflection; 6 | using Microsoft.OData.Edm; 7 | 8 | namespace Microsoft.OData.ModelBuilder 9 | { 10 | /// 11 | /// Represents a mapping from an to a CLR property info. 12 | /// 13 | public class ClrPropertyInfoAnnotation 14 | { 15 | /// 16 | /// Initializes a new instance of class. 17 | /// 18 | /// The backing CLR property info for the EDM property. 19 | public ClrPropertyInfoAnnotation(PropertyInfo clrPropertyInfo) 20 | { 21 | ClrPropertyInfo = clrPropertyInfo ?? throw new ArgumentNullException(nameof(clrPropertyInfo)); 22 | } 23 | 24 | /// 25 | /// Gets the backing CLR property info for the EDM property. 26 | /// 27 | public PropertyInfo ClrPropertyInfo { get; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Annotations/ClrTypeAnnotation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using Microsoft.OData.Edm; 6 | 7 | namespace Microsoft.OData.ModelBuilder 8 | { 9 | /// 10 | /// Represents a mapping from an to a CLR type. 11 | /// 12 | public class ClrTypeAnnotation 13 | { 14 | /// 15 | /// Initializes a new instance of class. 16 | /// 17 | /// The backing CLR type for the EDM type. It could be null. 18 | public ClrTypeAnnotation(Type clrType) 19 | { 20 | ClrType = clrType; 21 | } 22 | 23 | /// 24 | /// Gets the backing CLR type for the EDM type. 25 | /// 26 | public Type ClrType { get; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Annotations/ConcurrencyPropertiesAnnotation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Collections.Concurrent; 5 | using System.Collections.Generic; 6 | using System.Diagnostics.CodeAnalysis; 7 | using Microsoft.OData.Edm; 8 | 9 | namespace Microsoft.OData.ModelBuilder 10 | { 11 | /// 12 | /// Annotation to store cache for concurrency properties 13 | /// 14 | [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "Annotation suffix is more appropriate here.")] 15 | public class ConcurrencyPropertiesAnnotation : ConcurrentDictionary> 16 | { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Annotations/DynamicPropertyDictionaryAnnotation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | using System.Reflection; 6 | using Microsoft.OData.Edm; 7 | 8 | namespace Microsoft.OData.ModelBuilder 9 | { 10 | /// 11 | /// This annotation indicates the mapping from a to a . 12 | /// The is an open type and the is the specific 13 | /// property which is used in an open type to save/retrieve the dynamic properties. 14 | /// 15 | public class DynamicPropertyDictionaryAnnotation 16 | { 17 | /// 18 | /// Initializes a new instance of class. 19 | /// 20 | /// The backing . 21 | public DynamicPropertyDictionaryAnnotation(PropertyInfo propertyInfo) 22 | { 23 | if (propertyInfo == null) 24 | { 25 | throw Error.ArgumentNull("propertyInfo"); 26 | } 27 | 28 | if (!typeof(IDictionary).IsAssignableFrom(propertyInfo.PropertyType)) 29 | { 30 | throw Error.Argument("propertyInfo", SRResources.InvalidPropertyInfoForDynamicPropertyAnnotation, 31 | propertyInfo.PropertyType.Name, 32 | "IDictionary"); 33 | } 34 | 35 | PropertyInfo = propertyInfo; 36 | } 37 | 38 | /// 39 | /// Gets the which backs the dynamic properties of the open type. 40 | /// 41 | public PropertyInfo PropertyInfo { get; } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Annotations/InstanceAnnotationContainerAnnotation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Reflection; 5 | using Microsoft.OData.Edm; 6 | 7 | namespace Microsoft.OData.ModelBuilder 8 | { 9 | /// 10 | /// This annotation indicates the mapping from a to a . 11 | /// The is a type of IODataInstanceAnnotationContainer and the is the specific 12 | /// property which is used to save/retrieve the instance annotations. 13 | /// 14 | public class InstanceAnnotationContainerAnnotation 15 | { 16 | /// 17 | /// Initializes a new instance of class. 18 | /// 19 | /// The backing . 20 | public InstanceAnnotationContainerAnnotation(PropertyInfo propertyInfo) 21 | { 22 | if (propertyInfo == null) 23 | { 24 | throw Error.ArgumentNull(nameof(propertyInfo)); 25 | } 26 | 27 | if (!typeof(IODataInstanceAnnotationContainer).IsAssignableFrom(propertyInfo.PropertyType)) 28 | { 29 | throw Error.Argument("propertyInfo", SRResources.ArgumentMustBeOfType, "IODataInstanceAnnotationContainer"); 30 | } 31 | 32 | PropertyInfo = propertyInfo; 33 | } 34 | 35 | /// 36 | /// Gets the which backs the instance annotations of the clr type/resource etc. 37 | /// 38 | public PropertyInfo PropertyInfo { get; } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Annotations/OperationTitleAnnotation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Represents a annotation for the Operation title. 10 | /// 11 | public class OperationTitleAnnotation 12 | { 13 | /// 14 | /// Initializes a new instance of class. 15 | /// 16 | /// The operation title. 17 | public OperationTitleAnnotation(string title) 18 | { 19 | Title = title ?? throw new ArgumentNullException(nameof(title)); 20 | } 21 | 22 | /// 23 | /// Gets the operation title. 24 | /// 25 | public string Title { get; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Annotations/QueryableRestrictionsAnnotation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using Microsoft.OData.ModelBuilder.Config; 6 | 7 | namespace Microsoft.OData.ModelBuilder.Annotations 8 | { 9 | /// 10 | /// Represents an annotation to add the queryable restrictions on an EDM property, including not filterable, 11 | /// not sortable, not navigable, not expandable, not countable, automatically expand. 12 | /// 13 | public class QueryableRestrictionsAnnotation 14 | { 15 | /// 16 | /// Initializes a new instance of class. 17 | /// 18 | /// The queryable restrictions for the EDM property. 19 | public QueryableRestrictionsAnnotation(QueryableRestrictions restrictions) 20 | { 21 | Restrictions = restrictions ?? throw new ArgumentNullException(nameof(restrictions)); 22 | } 23 | 24 | /// 25 | /// Gets the restrictions for the EDM property. 26 | /// 27 | public QueryableRestrictions Restrictions { get; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Annotations/ReturnedEntitySetAnnotation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using Microsoft.OData.Edm; 6 | 7 | namespace Microsoft.OData.ModelBuilder 8 | { 9 | /// 10 | /// This annotation indicates the mapping from an to a . 11 | /// The is a bound action/function and the is the 12 | /// entity set name given by user to indicate the entity set returned from this action/function. 13 | /// 14 | public class ReturnedEntitySetAnnotation 15 | { 16 | /// 17 | /// Initializes a new instance of class. 18 | /// 19 | /// The return entity set or singleton name 20 | public ReturnedEntitySetAnnotation(string entitySetName) 21 | { 22 | if (string.IsNullOrEmpty(entitySetName)) 23 | { 24 | throw Error.ArgumentNullOrEmpty("entitySetName"); 25 | } 26 | 27 | EntitySetName = entitySetName; 28 | } 29 | 30 | /// 31 | /// Gets the entity set name 32 | /// 33 | public string EntitySetName { get; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/ActionOnDeleteAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using Microsoft.OData.Edm; 6 | 7 | namespace Microsoft.OData.ModelBuilder 8 | { 9 | /// 10 | /// Represents an that can be placed on a navigation property to specify the applied 11 | /// action whether delete should also remove the associated item on the other end of the association. 12 | /// 13 | [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] 14 | public sealed class ActionOnDeleteAttribute : Attribute 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The action applied on delete. 20 | public ActionOnDeleteAttribute(EdmOnDeleteAction onDeleteAction) 21 | { 22 | OnDeleteAction = onDeleteAction; 23 | } 24 | 25 | /// 26 | /// Gets the action whether delete should also remove the associated item on the other end of the association. 27 | /// 28 | public EdmOnDeleteAction OnDeleteAction { get; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/AutoExpandAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Represents an that can be placed on a navigation property to specify it 10 | /// is auto expanded, or placed on a class to specify all navigation properties are auto expanded. 11 | /// 12 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class)] 13 | public sealed class AutoExpandAttribute : Attribute 14 | { 15 | /// 16 | /// Gets or sets whether the automatic expand will be disabled if there is a $select specify by client. 17 | /// 18 | public bool DisableWhenSelectPresent { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/ContainedAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Mark a navigation property as containment. 10 | /// 11 | [AttributeUsage(AttributeTargets.Property)] 12 | public sealed class ContainedAttribute : Attribute 13 | { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/CountAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Represents an that can be placed on a class or property 10 | /// correlate to OData's $count query option settings. 11 | /// 12 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class)] 13 | public sealed class CountAttribute : Attribute 14 | { 15 | /// 16 | /// Represents whether the $count can be applied on the property or the entityset. 17 | /// 18 | public bool Disabled { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/MediaTypeAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Marks this entity type as media type. 10 | /// 11 | [AttributeUsage(AttributeTargets.Class)] 12 | public sealed class MediaTypeAttribute : Attribute 13 | { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/NonFilterableAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Represents an that can be placed on a property to specify that the property cannot be used in the $filter OData query option. 10 | /// 11 | [AttributeUsage(AttributeTargets.Property)] 12 | public sealed class NonFilterableAttribute : Attribute 13 | { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/NotCountableAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Represents an that can be placed on a property to specify that 10 | /// the $count cannot be applied on the property. 11 | /// 12 | [AttributeUsage(AttributeTargets.Property)] 13 | public sealed class NotCountableAttribute : Attribute 14 | { 15 | } 16 | } -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/NotExpandableAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Represents an that can be placed on a property to specify that the property cannot be used in the $expand OData query option. 10 | /// 11 | [AttributeUsage(AttributeTargets.Property)] 12 | public sealed class NotExpandableAttribute : Attribute 13 | { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/NotFilterableAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Represents an that can be placed on a property to specify that 10 | /// the property cannot be used in the $filter OData query option. 11 | /// 12 | [AttributeUsage(AttributeTargets.Property)] 13 | public sealed class NotFilterableAttribute : Attribute 14 | { 15 | } 16 | } -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/NotNavigableAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Represents an that can be placed on a property to specify that the property cannot be navigated in OData query. 10 | /// 11 | [AttributeUsage(AttributeTargets.Property)] 12 | public sealed class NotNavigableAttribute : Attribute 13 | { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/NotSortableAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Represents an that can be placed on a property to specify that 10 | /// the property cannot be used in the $orderby OData query option. 11 | /// 12 | [AttributeUsage(AttributeTargets.Property)] 13 | public sealed class NotSortableAttribute : Attribute 14 | { 15 | } 16 | } -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/PageAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Represents an that can be placed on a property or a class to specify that 10 | /// the maximum value of $top and query result return number of that property or type. 11 | /// 12 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class)] 13 | public sealed class PageAttribute : Attribute 14 | { 15 | private int _maxTop = -1; 16 | 17 | /// 18 | /// Sets the max value of $top that a client can request. 19 | /// 20 | public int MaxTop 21 | { 22 | get 23 | { 24 | return _maxTop; 25 | } 26 | set 27 | { 28 | _maxTop = value; 29 | } 30 | } 31 | 32 | /// 33 | /// Sets the maximum number of query results to return. 34 | /// 35 | public int PageSize { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/SelectExpandType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder 5 | { 6 | /// 7 | /// Represents the type of expand and select. 8 | /// 9 | public enum SelectExpandType 10 | { 11 | /// 12 | /// Allowed to be expanded and selected. 13 | /// 14 | Allowed, 15 | 16 | /// 17 | /// Automatic expanded and selected. 18 | /// 19 | Automatic, 20 | 21 | /// 22 | /// Disallowed to be expanded and selected. 23 | /// 24 | Disabled 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/SingletonAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Represents an that can be placed on a property to specify 10 | /// that the property must bind to a singleton. It's used in convention model builder. 11 | /// 12 | [AttributeUsage(AttributeTargets.Property)] 13 | public sealed class SingletonAttribute : Attribute 14 | { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Attributes/UnsortableAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Represents an that can be placed on a property to specify that the property cannot be used in the $orderby OData query option. 10 | /// 11 | [AttributeUsage(AttributeTargets.Property)] 12 | public sealed class UnsortableAttribute : Attribute 13 | { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Config/ExpandConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Config 5 | { 6 | /// 7 | /// Represents a configuration of an expandable property. 8 | /// 9 | public class ExpandConfiguration 10 | { 11 | /// 12 | /// Gets or sets the . 13 | /// 14 | public SelectExpandType ExpandType { get; set; } 15 | 16 | /// 17 | /// Gets or sets the maximum depth. 18 | /// 19 | public int MaxDepth { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Containers/BindingPathHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Reflection; 8 | 9 | namespace Microsoft.OData.ModelBuilder 10 | { 11 | internal static class BindingPathHelper 12 | { 13 | /// 14 | /// Converts the binding path list to string. like "A.B/C/D.E". 15 | /// 16 | /// The binding path list. 17 | /// The binding path string. like "A.B/C/D.E". 18 | public static string ConvertBindingPath(this IEnumerable bindingPath) 19 | { 20 | if (bindingPath == null) 21 | { 22 | throw Error.ArgumentNull("bindingPath"); 23 | } 24 | 25 | return String.Join("/", bindingPath.Select(e => TypeHelper.GetQualifiedName(e))); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Containers/EntitySetConfigurationOfTEntityType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using Microsoft.OData.Edm; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Represents an that can be built using . 10 | /// The element type of the entity set. 11 | /// 12 | public class EntitySetConfiguration : NavigationSourceConfiguration 13 | where TEntityType : class 14 | { 15 | internal EntitySetConfiguration(ODataModelBuilder modelBuilder, string name) 16 | : base(modelBuilder, new EntitySetConfiguration(modelBuilder, typeof(TEntityType), name)) 17 | { 18 | } 19 | 20 | internal EntitySetConfiguration(ODataModelBuilder modelBuilder, EntitySetConfiguration configuration) 21 | : base(modelBuilder, configuration) 22 | { 23 | } 24 | 25 | internal EntitySetConfiguration EntitySet 26 | { 27 | get { return (EntitySetConfiguration)Configuration; } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Containers/IODataInstanceAnnotationContainer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Interface to used as a Container for holding Instance Annotations, An default implementation is provided 10 | /// Customer can implement the interface and can have their own implementation. 11 | /// 12 | public interface IODataInstanceAnnotationContainer 13 | { 14 | /// 15 | /// Gets the instance annotation. 16 | /// If the key is null, it's for the CLR type instance annotations. 17 | /// If the key is not null, it's for the property instance annotations. 18 | /// 19 | IDictionary> InstanceAnnotations { get; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Containers/NavigationPropertyBindingOption.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder 5 | { 6 | /// 7 | /// Options for navigation property binding. 8 | /// 9 | public enum NavigationPropertyBindingOption 10 | { 11 | /// 12 | /// Default behavior. It won't auto create the navigation property binding if multiple navigation sources. 13 | /// 14 | None = 0, 15 | 16 | /// 17 | /// Auto binding behavior. It will automatically pick the first one of target navigation sources. 18 | /// 19 | Auto = 1, 20 | } 21 | } -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Containers/ODataInstanceAnnotationContainer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Default implementation for 10 | /// 11 | public class ODataInstanceAnnotationContainer : IODataInstanceAnnotationContainer 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | public ODataInstanceAnnotationContainer() 17 | { 18 | InstanceAnnotations = new Dictionary>(); 19 | } 20 | 21 | /// 22 | /// Gets the instance annotations 23 | /// 24 | public IDictionary> InstanceAnnotations { get; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Containers/SingletonConfigurationOfTEntityType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using Microsoft.OData.Edm; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Represents an that can be built using . 10 | /// 11 | public class SingletonConfiguration : NavigationSourceConfiguration where TEntityType : class 12 | { 13 | internal SingletonConfiguration(ODataModelBuilder modelBuilder, string name) 14 | : base(modelBuilder, new SingletonConfiguration(modelBuilder, typeof(TEntityType), name)) 15 | { 16 | } 17 | 18 | internal SingletonConfiguration(ODataModelBuilder modelBuilder, SingletonConfiguration configuration) 19 | : base(modelBuilder, configuration) 20 | { 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/AbstractTypeDiscoveryConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder 5 | { 6 | /// 7 | /// to figure out if a structural type is abstract or not. 8 | /// This convention configures all structural types backed by an abstract CLR type as abstract. 9 | /// 10 | internal class AbstractTypeDiscoveryConvention : IEdmTypeConvention 11 | { 12 | public void Apply(IEdmTypeConfiguration edmTypeConfiguration, ODataConventionModelBuilder model) 13 | { 14 | StructuralTypeConfiguration structuralType = edmTypeConfiguration as StructuralTypeConfiguration; 15 | if (structuralType != null && structuralType.IsAbstract == null) 16 | { 17 | structuralType.IsAbstract = TypeHelper.IsAbstract(structuralType.ClrType); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/ActionOnDeleteAttributeConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Linq; 6 | 7 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 8 | { 9 | internal class ActionOnDeleteAttributeConvention : AttributeEdmPropertyConvention 10 | { 11 | public ActionOnDeleteAttributeConvention() 12 | : base(attribute => attribute.GetType() == typeof(ActionOnDeleteAttribute), allowMultiple: false) 13 | { 14 | } 15 | 16 | public override void Apply(NavigationPropertyConfiguration edmProperty, 17 | StructuralTypeConfiguration structuralTypeConfiguration, Attribute attribute, ODataConventionModelBuilder model) 18 | { 19 | if (edmProperty == null) 20 | { 21 | throw Error.ArgumentNull("edmProperty"); 22 | } 23 | 24 | ActionOnDeleteAttribute actionOnDelete = attribute as ActionOnDeleteAttribute; 25 | if (actionOnDelete != null && !edmProperty.AddedExplicitly && edmProperty.DependentProperties.Any()) 26 | { 27 | edmProperty.OnDeleteAction = actionOnDelete.OnDeleteAction; 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/AutoExpandAttributeEdmPropertyConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 7 | { 8 | internal class AutoExpandAttributeEdmPropertyConvention : AttributeEdmPropertyConvention 9 | { 10 | public AutoExpandAttributeEdmPropertyConvention() 11 | : base(attribute => attribute.GetType() == typeof(AutoExpandAttribute), allowMultiple: false) 12 | { 13 | } 14 | 15 | public override void Apply(NavigationPropertyConfiguration edmProperty, 16 | StructuralTypeConfiguration structuralTypeConfiguration, 17 | Attribute attribute, 18 | ODataConventionModelBuilder model) 19 | { 20 | if (edmProperty == null) 21 | { 22 | throw Error.ArgumentNull("edmProperty"); 23 | } 24 | 25 | if (!edmProperty.AddedExplicitly) 26 | { 27 | AutoExpandAttribute autoExpandAttribute = attribute as AutoExpandAttribute; 28 | edmProperty.AutomaticallyExpand(autoExpandAttribute.DisableWhenSelectPresent); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/ComplexTypeAttributeConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.ComponentModel.DataAnnotations.Schema; 6 | using System.Linq; 7 | 8 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 9 | { 10 | internal class ComplexTypeAttributeConvention : AttributeEdmTypeConvention 11 | { 12 | public ComplexTypeAttributeConvention() 13 | : base(attr => attr.GetType() == typeof(ComplexTypeAttribute), false) 14 | { 15 | } 16 | 17 | public override void Apply(EntityTypeConfiguration edmTypeConfiguration, ODataConventionModelBuilder model, 18 | Attribute attribute) 19 | { 20 | if (edmTypeConfiguration == null) 21 | { 22 | throw Error.ArgumentNull("edmTypeConfiguration"); 23 | } 24 | 25 | if (!edmTypeConfiguration.AddedExplicitly) 26 | { 27 | PrimitivePropertyConfiguration[] keys = edmTypeConfiguration.Keys.ToArray(); 28 | foreach (PrimitivePropertyConfiguration key in keys) 29 | { 30 | edmTypeConfiguration.RemoveKey(key); 31 | } 32 | 33 | EnumPropertyConfiguration[] enumKeys = edmTypeConfiguration.EnumKeys.ToArray(); 34 | foreach (EnumPropertyConfiguration key in enumKeys) 35 | { 36 | edmTypeConfiguration.RemoveKey(key); 37 | } 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/CountAttributeEdmPropertyConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 7 | { 8 | internal class CountAttributeEdmPropertyConvention : AttributeEdmPropertyConvention 9 | { 10 | public CountAttributeEdmPropertyConvention() 11 | : base(attribute => attribute.GetType() == typeof(CountAttribute), allowMultiple: false) 12 | { 13 | } 14 | 15 | public override void Apply(PropertyConfiguration edmProperty, 16 | StructuralTypeConfiguration structuralTypeConfiguration, 17 | Attribute attribute, 18 | ODataConventionModelBuilder model) 19 | { 20 | if (edmProperty == null) 21 | { 22 | throw Error.ArgumentNull("edmProperty"); 23 | } 24 | 25 | if (!edmProperty.AddedExplicitly) 26 | { 27 | CountAttribute countAttribute = attribute as CountAttribute; 28 | if (countAttribute.Disabled) 29 | { 30 | edmProperty.QueryConfiguration.GetModelBoundQuerySettingsOrDefault().Countable = false; 31 | } 32 | else 33 | { 34 | edmProperty.QueryConfiguration.GetModelBoundQuerySettingsOrDefault().Countable = true; 35 | } 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/MediaTypeAttributeConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 7 | { 8 | internal class MediaTypeAttributeConvention : AttributeEdmTypeConvention 9 | { 10 | public MediaTypeAttributeConvention() 11 | : base(attr => attr.GetType() == typeof(MediaTypeAttribute), false) 12 | { 13 | } 14 | 15 | public override void Apply(EntityTypeConfiguration edmTypeConfiguration, ODataConventionModelBuilder model, 16 | Attribute attribute) 17 | { 18 | if (edmTypeConfiguration == null) 19 | { 20 | throw Error.ArgumentNull("edmTypeConfiguration"); 21 | } 22 | 23 | edmTypeConfiguration.MediaType(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/NonFilterableAttributeEdmPropertyConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 7 | { 8 | internal class NonFilterableAttributeEdmPropertyConvention : AttributeEdmPropertyConvention 9 | { 10 | public NonFilterableAttributeEdmPropertyConvention() 11 | : base(attribute => attribute.GetType() == typeof(NonFilterableAttribute), allowMultiple: false) 12 | { 13 | } 14 | 15 | public override void Apply(PropertyConfiguration edmProperty, 16 | StructuralTypeConfiguration structuralTypeConfiguration, 17 | Attribute attribute, 18 | ODataConventionModelBuilder model) 19 | { 20 | if (edmProperty == null) 21 | { 22 | throw Error.ArgumentNull("edmProperty"); 23 | } 24 | 25 | if (!edmProperty.AddedExplicitly) 26 | { 27 | edmProperty.IsNotFilterable(); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/NotCountableAttributeEdmPropertyConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 7 | { 8 | internal class NotCountableAttributeEdmPropertyConvention : AttributeEdmPropertyConvention 9 | { 10 | public NotCountableAttributeEdmPropertyConvention() 11 | : base(attribute => attribute.GetType() == typeof(NotCountableAttribute), allowMultiple: false) 12 | { 13 | } 14 | 15 | public override void Apply(PropertyConfiguration edmProperty, 16 | StructuralTypeConfiguration structuralTypeConfiguration, 17 | Attribute attribute, 18 | ODataConventionModelBuilder model) 19 | { 20 | if (edmProperty == null) 21 | { 22 | throw Error.ArgumentNull("edmProperty"); 23 | } 24 | 25 | if (!edmProperty.AddedExplicitly) 26 | { 27 | edmProperty.IsNotCountable(); 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/NotExpandableAttributeEdmPropertyConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 7 | { 8 | internal class NotExpandableAttributeEdmPropertyConvention : AttributeEdmPropertyConvention 9 | { 10 | public NotExpandableAttributeEdmPropertyConvention() 11 | : base(attribute => attribute.GetType() == typeof(NotExpandableAttribute), allowMultiple: false) 12 | { 13 | } 14 | 15 | public override void Apply(NavigationPropertyConfiguration edmProperty, 16 | StructuralTypeConfiguration structuralTypeConfiguration, 17 | Attribute attribute, 18 | ODataConventionModelBuilder model) 19 | { 20 | if (edmProperty == null) 21 | { 22 | throw Error.ArgumentNull("edmProperty"); 23 | } 24 | 25 | if (!edmProperty.AddedExplicitly) 26 | { 27 | edmProperty.IsNotExpandable(); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/NotFilterableAttributeEdmPropertyConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 7 | { 8 | internal class NotFilterableAttributeEdmPropertyConvention : AttributeEdmPropertyConvention 9 | { 10 | public NotFilterableAttributeEdmPropertyConvention() 11 | : base(attribute => attribute.GetType() == typeof(NotFilterableAttribute), allowMultiple: false) 12 | { 13 | } 14 | 15 | public override void Apply(PropertyConfiguration edmProperty, 16 | StructuralTypeConfiguration structuralTypeConfiguration, 17 | Attribute attribute, 18 | ODataConventionModelBuilder model) 19 | { 20 | if (edmProperty == null) 21 | { 22 | throw Error.ArgumentNull("edmProperty"); 23 | } 24 | 25 | if (!edmProperty.AddedExplicitly) 26 | { 27 | edmProperty.IsNotFilterable(); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/NotMappedAttributeEdmPropertyConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using Microsoft.OData.Edm; 6 | 7 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 8 | { 9 | /// 10 | /// Ignores properties with the NotMappedAttribute from . 11 | /// 12 | internal class NotMappedAttributeConvention : AttributeEdmPropertyConvention 13 | { 14 | // .net 4.5 NotMappedAttribute has the same name. 15 | private const string EntityFrameworkNotMappedAttributeTypeName = "System.ComponentModel.DataAnnotations.Schema.NotMappedAttribute"; 16 | 17 | private static Func _filter = attribute => 18 | { 19 | return attribute.GetType().FullName.Equals(EntityFrameworkNotMappedAttributeTypeName, StringComparison.Ordinal); 20 | }; 21 | 22 | public NotMappedAttributeConvention() 23 | : base(_filter, allowMultiple: false) 24 | { 25 | } 26 | 27 | public override void Apply(PropertyConfiguration edmProperty, 28 | StructuralTypeConfiguration structuralTypeConfiguration, 29 | Attribute attribute, 30 | ODataConventionModelBuilder model) 31 | { 32 | if (edmProperty == null) 33 | { 34 | throw Error.ArgumentNull("edmProperty"); 35 | } 36 | 37 | if (structuralTypeConfiguration == null) 38 | { 39 | throw Error.ArgumentNull("structuralTypeConfiguration"); 40 | } 41 | 42 | if (!edmProperty.AddedExplicitly) 43 | { 44 | structuralTypeConfiguration.RemoveProperty(edmProperty.PropertyInfo); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/NotNavigableAttributeEdmPropertyConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 7 | { 8 | internal class NotNavigableAttributeEdmPropertyConvention : AttributeEdmPropertyConvention 9 | { 10 | public NotNavigableAttributeEdmPropertyConvention() 11 | : base(attribute => attribute.GetType() == typeof(NotNavigableAttribute), allowMultiple: false) 12 | { 13 | } 14 | 15 | public override void Apply(NavigationPropertyConfiguration edmProperty, 16 | StructuralTypeConfiguration structuralTypeConfiguration, 17 | Attribute attribute, 18 | ODataConventionModelBuilder model) 19 | { 20 | if (edmProperty == null) 21 | { 22 | throw Error.ArgumentNull("edmProperty"); 23 | } 24 | 25 | if (!edmProperty.AddedExplicitly) 26 | { 27 | edmProperty.IsNotNavigable(); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/NotSortableAttributeEdmPropertyConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 7 | { 8 | internal class NotSortableAttributeEdmPropertyConvention : AttributeEdmPropertyConvention 9 | { 10 | public NotSortableAttributeEdmPropertyConvention() 11 | : base(attribute => attribute.GetType() == typeof(NotSortableAttribute), allowMultiple: false) 12 | { 13 | } 14 | 15 | public override void Apply(PropertyConfiguration edmProperty, 16 | StructuralTypeConfiguration structuralTypeConfiguration, 17 | Attribute attribute, 18 | ODataConventionModelBuilder model) 19 | { 20 | if (edmProperty == null) 21 | { 22 | throw Error.ArgumentNull("edmProperty"); 23 | } 24 | 25 | if (!edmProperty.AddedExplicitly) 26 | { 27 | edmProperty.IsNotSortable(); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/PageAttributeEdmPropertyConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using Microsoft.OData.ModelBuilder.Config; 6 | 7 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 8 | { 9 | internal class PageAttributeEdmPropertyConvention : AttributeEdmPropertyConvention 10 | { 11 | public PageAttributeEdmPropertyConvention() 12 | : base(attribute => attribute.GetType() == typeof(PageAttribute), allowMultiple: false) 13 | { 14 | } 15 | 16 | public override void Apply(PropertyConfiguration edmProperty, 17 | StructuralTypeConfiguration structuralTypeConfiguration, 18 | Attribute attribute, 19 | ODataConventionModelBuilder model) 20 | { 21 | if (edmProperty == null) 22 | { 23 | throw Error.ArgumentNull("edmProperty"); 24 | } 25 | 26 | if (!edmProperty.AddedExplicitly) 27 | { 28 | PageAttribute pageAttribute = attribute as PageAttribute; 29 | 30 | ModelBoundQuerySettings querySettings = edmProperty.QueryConfiguration.GetModelBoundQuerySettingsOrDefault(); 31 | if (pageAttribute.MaxTop < 0) 32 | { 33 | querySettings.MaxTop = null; 34 | } 35 | else 36 | { 37 | querySettings.MaxTop = pageAttribute.MaxTop; 38 | } 39 | 40 | if (pageAttribute.PageSize > 0) 41 | { 42 | querySettings.PageSize = pageAttribute.PageSize; 43 | } 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/PropertyAttributeConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 5 | { 6 | /// 7 | /// Base class for all attribute based conventions. 8 | /// 9 | public abstract class PropertyAttributeConvention : AttributeConvention 10 | { 11 | /// 12 | /// Initializes a new instance of . 13 | /// 14 | public PropertyAttributeConvention() 15 | : base(attribute => attribute.GetType() == typeof(TAttribute), allowMultiple: false) 16 | { 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/TypeAttributeConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 5 | { 6 | /// 7 | /// Base class for all attribute based conventions. 8 | /// 9 | public abstract class TypeAttributeConvention : AttributeConvention 10 | { 11 | /// 12 | /// Initializes a new instance of . 13 | /// 14 | public TypeAttributeConvention() 15 | : base(attribute => attribute.GetType() == typeof(TAttribute), allowMultiple: false) 16 | { 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/Attributes/UnsortableAttributeEdmPropertyConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Conventions.Attributes 7 | { 8 | internal class UnsortableAttributeEdmPropertyConvention : AttributeEdmPropertyConvention 9 | { 10 | public UnsortableAttributeEdmPropertyConvention() 11 | : base(attribute => attribute.GetType() == typeof(UnsortableAttribute), allowMultiple: false) 12 | { 13 | } 14 | 15 | public override void Apply(PropertyConfiguration edmProperty, 16 | StructuralTypeConfiguration structuralTypeConfiguration, 17 | Attribute attribute, 18 | ODataConventionModelBuilder model) 19 | { 20 | if (edmProperty == null) 21 | { 22 | throw Error.ArgumentNull("edmProperty"); 23 | } 24 | 25 | if (!edmProperty.AddedExplicitly) 26 | { 27 | edmProperty.IsNotSortable(); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/EntityTypeConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder 5 | { 6 | /// 7 | /// An is used to configure an in the 8 | /// . 9 | /// 10 | internal abstract class EntityTypeConvention : IEdmTypeConvention 11 | { 12 | protected EntityTypeConvention() 13 | { 14 | } 15 | 16 | public void Apply(IEdmTypeConfiguration edmTypeConfiguration, ODataConventionModelBuilder model) 17 | { 18 | EntityTypeConfiguration entity = edmTypeConfiguration as EntityTypeConfiguration; 19 | if (entity != null) 20 | { 21 | Apply(entity, model); 22 | } 23 | } 24 | 25 | /// 26 | /// Applies the convention. 27 | /// 28 | /// The to apply the convention on. 29 | /// The instance. 30 | public abstract void Apply(EntityTypeConfiguration entity, ODataConventionModelBuilder model); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/IEdmPropertyConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder 5 | { 6 | /// 7 | /// Convention to process properties of . 8 | /// 9 | internal interface IEdmPropertyConvention : IODataModelConvention 10 | { 11 | /// 12 | /// Applies the convention. 13 | /// 14 | /// The property the convention is applied on. 15 | /// The the edmProperty belongs to. 16 | /// The that contains the type this property is being applied to. 17 | void Apply(PropertyConfiguration edmProperty, StructuralTypeConfiguration structuralTypeConfiguration, 18 | ODataConventionModelBuilder model); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/IEdmPropertyConventionOfTPropertyConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder 5 | { 6 | /// 7 | /// Convention to process properties of . 8 | /// 9 | /// 10 | internal interface IEdmPropertyConvention : IEdmPropertyConvention 11 | where TPropertyConfiguration : PropertyConfiguration 12 | { 13 | /// 14 | /// Applies the convention. 15 | /// 16 | /// The property the convention is applied on. 17 | /// The the edmProperty belongs to. 18 | /// The that contains the type this property is being applied to. 19 | void Apply(TPropertyConfiguration edmProperty, StructuralTypeConfiguration structuralTypeConfiguration, 20 | ODataConventionModelBuilder model); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/IEdmTypeConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder 5 | { 6 | internal interface IEdmTypeConvention : IODataModelConvention 7 | { 8 | void Apply(IEdmTypeConfiguration edmTypeConfiguration, ODataConventionModelBuilder model); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/INavigationSourceConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Conventions 5 | { 6 | /// 7 | /// Convention to apply to instances in the model 8 | /// 9 | internal interface INavigationSourceConvention : IODataModelConvention 10 | { 11 | void Apply(NavigationSourceConfiguration configuration, ODataModelBuilder model); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/IODataModelConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Diagnostics.CodeAnalysis; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// 10 | /// 11 | [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces", Justification = "Marker interface acceptable here for derivation")] 12 | public interface IODataModelConvention 13 | { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/IODataModelConventionSetBuilder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Conventions 5 | { 6 | /// 7 | /// Represents a set of conventions used to build an Edm model. 8 | /// 9 | public interface IODataModelConventionSetBuilder 10 | { 11 | /// 12 | /// Builds and returns the convention set to use. 13 | /// 14 | /// The convention set to use. 15 | ODataModelConventionSet Build(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/IOperationConvention.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder 5 | { 6 | /// 7 | /// Convention to apply to instances in the model 8 | /// 9 | internal interface IOperationConvention : IODataModelConvention 10 | { 11 | void Apply(OperationConfiguration configuration, ODataModelBuilder model); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Conventions/ODataModelConventionSet.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Conventions 5 | { 6 | /// 7 | /// Represents a set of conventions used to build an Edm model. 8 | /// 9 | public class ODataModelConventionSet 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Helpers/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT license. 3 | 4 | using System.Reflection; 5 | using System.Resources; 6 | using System.Runtime.CompilerServices; 7 | 8 | [assembly:InternalsVisibleTo("Microsoft.OData.ModelBuilder.Tests," + 9 | " PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] 10 | 11 | [assembly: NeutralResourcesLanguage("en-US")] 12 | 13 | [assembly: AssemblyTitle("Microsoft.OData.ModelBuilder")] 14 | 15 | [assembly: AssemblyProduct("Microsoft OData Edm (Entity Data Model) builder")] -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Helpers/DefaultAssemblyResolver.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Reflection; 7 | 8 | namespace Microsoft.OData.ModelBuilder 9 | { 10 | /// 11 | /// Default implementation of 12 | /// 13 | public class DefaultAssemblyResolver : IAssemblyResolver 14 | { 15 | private Assembly[] _assemblies = GetAssembliesInteral(); 16 | 17 | /// 18 | /// This static instance is used in the shared code in places where the request container context 19 | /// is not known or does not contain an instance of IWebApiAssembliesResolver. 20 | /// 21 | internal static IAssemblyResolver Default = new DefaultAssemblyResolver(); 22 | 23 | /// 24 | /// Gets the assemblies. 25 | /// 26 | public IEnumerable Assemblies => _assemblies; 27 | 28 | private static Assembly[] GetAssembliesInteral() 29 | { 30 | return AppDomain.CurrentDomain.GetAssemblies(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Helpers/IAssemblyResolver.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | using System.Reflection; 6 | 7 | namespace Microsoft.OData.ModelBuilder 8 | { 9 | /// 10 | /// The Assembly resolver interface. 11 | /// 12 | public interface IAssemblyResolver 13 | { 14 | /// 15 | /// Gets a list of assemblies available for the application. 16 | /// 17 | /// A list of assemblies available for the application. 18 | IEnumerable Assemblies { get; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Helpers/NavigationSourceAndAnnotations.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using Microsoft.OData.Edm; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// This class is used in internal as a helper class to build the Edm model. 10 | /// This class wrappers a relationship between Edm type and the CLR type configuration. 11 | /// This relationship is used to builder the navigation property and the corresponding links. 12 | /// 13 | internal class NavigationSourceAndAnnotations 14 | { 15 | public EdmNavigationSource NavigationSource { get; set; } 16 | public NavigationSourceConfiguration Configuration { get; set; } 17 | public NavigationSourceLinkBuilderAnnotation LinkBuilder { get; set; } 18 | public NavigationSourceUrlAnnotation Url { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Helpers/NavigationSourceUrlAnnotation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder 5 | { 6 | // An internal class used in class. 7 | internal class NavigationSourceUrlAnnotation 8 | { 9 | public string Url { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.Nightly.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Microsoft.OData.ModelBuilder 5 | Microsoft OData Entity Data Model Builder 6 | $VersionFullSemantic$-Nightly$NightlyBuildVersion$ 7 | Microsoft 8 | © Microsoft Corporation. All rights reserved. 9 | This package contains APIs to create OData Edm (Entity Data Model) using C# types, attributes and conventions. 10 | en-US 11 | http://github.com/OData/ModelBuilder 12 | MIT 13 | true 14 | Microsoft OData Edm 15 | images\odata.png 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.Release.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Microsoft.OData.ModelBuilder 5 | Microsoft OData Entity Data Model Builder 6 | $VersionNuGetSemantic$ 7 | Microsoft 8 | © Microsoft Corporation. All rights reserved. 9 | This package contains APIs to create OData Edm (Entity Data Model) using C# types, attributes and conventions. 10 | https://docs.microsoft.com/en-us/odata/changelog/modelbuilder 11 | en-US 12 | http://github.com/OData/ModelBuilder 13 | MIT 14 | true 15 | Microsoft OData Edm 16 | images\odata.png 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/NameResolverOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Options for resolving names. 10 | /// 11 | [Flags] 12 | public enum NameResolverOptions 13 | { 14 | /// 15 | /// Process reflected property names. 16 | /// 17 | ProcessReflectedPropertyNames = 1, 18 | 19 | /// 20 | /// Process property names in DataMemberAttribute 21 | /// such as [DataMember(Name = "DataMemberCustomerName")]. 22 | /// 23 | ProcessDataMemberAttributePropertyNames = 2, 24 | 25 | /// 26 | /// Process explicit property names 27 | /// such as entityTypeConfiguration.Property(e => e.Key).Name="Id". 28 | /// 29 | ProcessExplicitPropertyNames = 4, 30 | 31 | /// 32 | /// Process Member Name in Enum 33 | /// 34 | ProcessEnumMemberNames = 8 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/ODataContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder 5 | { 6 | /// 7 | /// A context to model builder. 8 | /// 9 | internal class ODataContext 10 | { 11 | // TODO: it's not finished yet or (not started yet). 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Operations/NonbindingParameterConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder 5 | { 6 | /// 7 | /// Represents a non-binding operation parameter. 8 | /// 9 | /// Non binding parameters are provided in the POST body for Actions 10 | /// Non binding parameters are provided in 3 ways for Functions 11 | /// - ~/.../Function(p1=value) 12 | /// - ~/.../Function(p1=@x)?@x=value 13 | /// - ~/.../Function?p1=value (only allowed if the Function is the last url path segment). 14 | /// 15 | /// 16 | public class NonbindingParameterConfiguration : ParameterConfiguration 17 | { 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The name of the parameter. 22 | /// The EDM type of the parameter. 23 | public NonbindingParameterConfiguration(string name, IEdmTypeConfiguration parameterType) 24 | : base(name, parameterType) 25 | { 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Operations/OperationKind.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder 5 | { 6 | /// 7 | /// The Kind of OData Operation. 8 | /// 9 | public enum OperationKind 10 | { 11 | /// 12 | /// An action 13 | /// 14 | Action = 0, 15 | 16 | /// 17 | /// A function 18 | /// 19 | Function = 1, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Property/ComplexPropertyConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Reflection; 6 | 7 | namespace Microsoft.OData.ModelBuilder 8 | { 9 | /// 10 | /// Represents the configuration for a complex property of a structural type (an entity type or a complex type). 11 | /// 12 | public class ComplexPropertyConfiguration : StructuralPropertyConfiguration 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The property of the configuration. 18 | /// The declaring type of the property. 19 | public ComplexPropertyConfiguration(PropertyInfo property, StructuralTypeConfiguration declaringType) 20 | : base(property, declaringType) 21 | { 22 | } 23 | 24 | /// 25 | public override PropertyKind Kind => PropertyKind.Complex; 26 | 27 | /// 28 | public override Type RelatedClrType => PropertyInfo.PropertyType; 29 | 30 | /// 31 | /// Marks the current complex property as nullable. 32 | /// 33 | /// Returns itself so that multiple calls can be chained. 34 | public ComplexPropertyConfiguration IsNullable() 35 | { 36 | NullableProperty = true; 37 | return this; 38 | } 39 | 40 | /// 41 | /// Marks the current complex property as required (non-nullable). 42 | /// 43 | /// Returns itself so that multiple calls can be chained. 44 | public ComplexPropertyConfiguration IsRequired() 45 | { 46 | NullableProperty = false; 47 | return this; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Property/DecimalPropertyConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Reflection; 6 | 7 | namespace Microsoft.OData.ModelBuilder 8 | { 9 | /// 10 | /// Used to configure a decimal property of an entity type or complex type. 11 | /// This configuration functionality is exposed by the model builder Fluent API, see . 12 | /// 13 | public class DecimalPropertyConfiguration : PrecisionPropertyConfiguration 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The name of the property. 19 | /// The declaring EDM type of the property. 20 | public DecimalPropertyConfiguration(PropertyInfo property, StructuralTypeConfiguration declaringType) 21 | : base(property, declaringType) 22 | { 23 | } 24 | 25 | /// 26 | /// Gets or sets the maximum number of digits allowed to the right of the decimal point. 27 | /// 28 | public int? Scale { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Property/LengthPropertyConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Reflection; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Used to configure a string or binary property length of an entity type or complex type. 10 | /// This configuration functionality is exposed by the model builder Fluent API, see . 11 | /// 12 | public class LengthPropertyConfiguration : PrimitivePropertyConfiguration 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The name of the property. 18 | /// The declaring EDM type of the property. 19 | public LengthPropertyConfiguration(PropertyInfo property, StructuralTypeConfiguration declaringType) 20 | : base(property, declaringType) 21 | { 22 | } 23 | 24 | /// 25 | /// Gets or sets the maximum length of the value of the property on a type instance. 26 | /// 27 | public int? MaxLength { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Property/PrecisionPropertyConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Reflection; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Used to configure a datetime-with-offset, decimal, duration, or time-of-day property precision of an entity type or complex type. 10 | /// This configuration functionality is exposed by the model builder Fluent API, see . 11 | /// 12 | public class PrecisionPropertyConfiguration : PrimitivePropertyConfiguration 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The name of the property. 18 | /// The declaring EDM type of the property. 19 | public PrecisionPropertyConfiguration(PropertyInfo property, StructuralTypeConfiguration declaringType) 20 | : base(property, declaringType) 21 | { 22 | } 23 | 24 | /// 25 | /// Get or set the maximum number of digits allowed in the property’s value for decimal property. 26 | /// Get or set the number of decimal places allowed in the seconds portion of the property’s value for temporal property. 27 | /// 28 | public int? Precision { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Property/PropertyKind.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder 5 | { 6 | /// 7 | /// The kind of the EDM property. 8 | /// 9 | public enum PropertyKind 10 | { 11 | /// 12 | /// Represents an EDM primitive property. 13 | /// 14 | Primitive = 0, 15 | 16 | /// 17 | /// Represents an EDM complex property. 18 | /// 19 | Complex = 1, 20 | 21 | /// 22 | /// Represents an EDM collection property. 23 | /// 24 | Collection = 2, 25 | 26 | /// 27 | /// Represents an EDM navigation property. 28 | /// 29 | Navigation = 3, 30 | 31 | /// 32 | /// Represents an EDM enum property. 33 | /// 34 | Enum = 4, 35 | 36 | /// 37 | /// Represents a dynamic property dictionary for an open type. 38 | /// 39 | Dynamic = 5, 40 | 41 | /// 42 | /// Represents an instance annotation for a CLR type. 43 | /// 44 | InstanceAnnotations = 6, 45 | 46 | /// 47 | /// Represents an EDM untyped property 48 | /// 49 | Untyped = 7, 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Property/StructuralPropertyConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Reflection; 5 | 6 | namespace Microsoft.OData.ModelBuilder 7 | { 8 | /// 9 | /// Base class for all structural property configurations. 10 | /// 11 | public abstract class StructuralPropertyConfiguration : PropertyConfiguration 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// The property of the configuration. 17 | /// The declaring type of the property. 18 | protected StructuralPropertyConfiguration(PropertyInfo property, StructuralTypeConfiguration declaringType) 19 | : base(property, declaringType) 20 | { 21 | NullableProperty = EdmLibHelpers.IsNullable(property.PropertyType); 22 | } 23 | 24 | /// 25 | /// Gets or sets a value indicating whether this property is nullable or not. 26 | /// 27 | public bool NullableProperty { get; set; } 28 | 29 | /// 30 | /// Gets or sets a value indicating whether this property is a concurrency token or not. 31 | /// 32 | public bool ConcurrencyToken { get; set; } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Types/IEdmTypeConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Diagnostics.CodeAnalysis; 6 | using Microsoft.OData.Edm; 7 | 8 | namespace Microsoft.OData.ModelBuilder 9 | { 10 | /// 11 | /// Represents an EdmType which is associated with CLR type 12 | /// 13 | public interface IEdmTypeConfiguration 14 | { 15 | /// 16 | /// The CLR type associated with the EdmType. 17 | /// 18 | Type ClrType { get; } 19 | 20 | /// 21 | /// The fullname (including namespace) of the EdmType. 22 | /// 23 | string FullName { get; } 24 | 25 | /// 26 | /// The namespace of the EdmType. 27 | /// 28 | [SuppressMessage("Naming", "CA1716:Identifiers should not match keywords", Justification = "")] 29 | string Namespace { get; } 30 | 31 | /// 32 | /// The name of the EdmType. 33 | /// 34 | string Name { get; } 35 | 36 | /// 37 | /// The kind of the EdmType. 38 | /// Examples include EntityType, ComplexType, PrimitiveType, CollectionType, EnumType. 39 | /// 40 | EdmTypeKind Kind { get; } 41 | 42 | /// 43 | /// The ODataModelBuilder used to create this IEdmType. 44 | /// 45 | ODataModelBuilder ModelBuilder { get; } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/AcceptableEncodingsConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// List of acceptable compression methods for ($batch) requests, e.g. gzip 16 | /// 17 | public partial class AcceptableEncodingsConfiguration : VocabularyTermConfiguration 18 | { 19 | private readonly HashSet _acceptableEncodings = new HashSet(); 20 | 21 | /// 22 | public override string TermName => "Org.OData.Capabilities.V1.AcceptableEncodings"; 23 | 24 | /// 25 | /// List of acceptable compression methods for ($batch) requests, e.g. gzip 26 | /// 27 | /// The value(s) to set 28 | /// 29 | public AcceptableEncodingsConfiguration HasAcceptableEncodings(params string[] acceptableEncodings) 30 | { 31 | _acceptableEncodings.UnionWith(acceptableEncodings); 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | if (!_acceptableEncodings.Any()) 39 | { 40 | return null; 41 | } 42 | 43 | var records = _acceptableEncodings.Select(item => item.ToEdmExpression()); 44 | return new EdmCollectionExpression(records); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/AnnotationValuesInQuerySupportedConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Supports annotation values within system query options 16 | /// 17 | public partial class AnnotationValuesInQuerySupportedConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _annotationValuesInQuerySupported; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Capabilities.V1.AnnotationValuesInQuerySupported"; 23 | 24 | /// 25 | /// Supports annotation values within system query options 26 | /// 27 | /// The value to set 28 | /// 29 | public AnnotationValuesInQuerySupportedConfiguration IsAnnotationValuesInQuerySupported(bool annotationValuesInQuerySupported) 30 | { 31 | _annotationValuesInQuerySupported = annotationValuesInQuerySupported; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _annotationValuesInQuerySupported.HasValue ? new EdmBooleanConstant(_annotationValuesInQuerySupported.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/AsynchronousRequestsSupportedConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Service supports the asynchronous request preference 16 | /// 17 | public partial class AsynchronousRequestsSupportedConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _asynchronousRequestsSupported; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Capabilities.V1.AsynchronousRequestsSupported"; 23 | 24 | /// 25 | /// Service supports the asynchronous request preference 26 | /// 27 | /// The value to set 28 | /// 29 | public AsynchronousRequestsSupportedConfiguration IsAsynchronousRequestsSupported(bool asynchronousRequestsSupported) 30 | { 31 | _asynchronousRequestsSupported = asynchronousRequestsSupported; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _asynchronousRequestsSupported.HasValue ? new EdmBooleanConstant(_asynchronousRequestsSupported.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/BatchSupportedConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Supports $batch requests. Services that apply the BatchSupported term should also apply the more comprehensive BatchSupport term. 16 | /// 17 | public partial class BatchSupportedConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _batchSupported; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Capabilities.V1.BatchSupported"; 23 | 24 | /// 25 | /// Supports $batch requests. Services that apply the BatchSupported term should also apply the more comprehensive BatchSupport term. 26 | /// 27 | /// The value to set 28 | /// 29 | public BatchSupportedConfiguration IsBatchSupported(bool batchSupported) 30 | { 31 | _batchSupported = batchSupported; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _batchSupported.HasValue ? new EdmBooleanConstant(_batchSupported.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/ComputeSupportedConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Supports $compute 16 | /// 17 | public partial class ComputeSupportedConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _computeSupported; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Capabilities.V1.ComputeSupported"; 23 | 24 | /// 25 | /// Supports $compute 26 | /// 27 | /// The value to set 28 | /// 29 | public ComputeSupportedConfiguration IsComputeSupported(bool computeSupported) 30 | { 31 | _computeSupported = computeSupported; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _computeSupported.HasValue ? new EdmBooleanConstant(_computeSupported.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/ConformanceLevelType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Org.OData.Capabilities.V1.ConformanceLevelType 16 | /// 17 | public enum ConformanceLevelType 18 | { 19 | /// 20 | /// Minimal conformance level 21 | /// 22 | Minimal, 23 | 24 | /// 25 | /// Intermediate conformance level 26 | /// 27 | Intermediate, 28 | 29 | /// 30 | /// Advanced conformance level 31 | /// 32 | Advanced, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/CrossJoinSupportedConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Supports cross joins for the entity sets in this container 16 | /// 17 | public partial class CrossJoinSupportedConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _crossJoinSupported; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Capabilities.V1.CrossJoinSupported"; 23 | 24 | /// 25 | /// Supports cross joins for the entity sets in this container 26 | /// 27 | /// The value to set 28 | /// 29 | public CrossJoinSupportedConfiguration IsCrossJoinSupported(bool crossJoinSupported) 30 | { 31 | _crossJoinSupported = crossJoinSupported; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _crossJoinSupported.HasValue ? new EdmBooleanConstant(_crossJoinSupported.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/HttpMethod.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Org.OData.Capabilities.V1.HttpMethod 16 | /// 17 | [Flags] 18 | public enum HttpMethod 19 | { 20 | /// 21 | /// The HTTP GET Method 22 | /// 23 | GET, 24 | 25 | /// 26 | /// The HTTP PATCH Method 27 | /// 28 | PATCH, 29 | 30 | /// 31 | /// The HTTP PUT Method 32 | /// 33 | PUT, 34 | 35 | /// 36 | /// The HTTP POST Method 37 | /// 38 | POST, 39 | 40 | /// 41 | /// The HTTP DELETE Method 42 | /// 43 | DELETE, 44 | 45 | /// 46 | /// The HTTP OPTIONS Method 47 | /// 48 | OPTIONS, 49 | 50 | /// 51 | /// The HTTP HEAD Method 52 | /// 53 | HEAD, 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/IndexableByKeyConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Supports key values according to OData URL conventions 16 | /// 17 | public partial class IndexableByKeyConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _indexableByKey; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Capabilities.V1.IndexableByKey"; 23 | 24 | /// 25 | /// Supports key values according to OData URL conventions 26 | /// 27 | /// The value to set 28 | /// 29 | public IndexableByKeyConfiguration IsIndexableByKey(bool indexableByKey) 30 | { 31 | _indexableByKey = indexableByKey; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _indexableByKey.HasValue ? new EdmBooleanConstant(_indexableByKey.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/IsolationLevel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Org.OData.Capabilities.V1.IsolationLevel 16 | /// 17 | [Flags] 18 | public enum IsolationLevel 19 | { 20 | /// 21 | /// All data returned for a request, including multiple requests within a batch or results retrieved across multiple pages, will be consistent as of a single point in time 22 | /// 23 | Snapshot, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/KeyAsSegmentSupportedConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Supports [key-as-segment convention](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_KeyasSegmentConvention) for addressing entities within a collection 16 | /// 17 | public partial class KeyAsSegmentSupportedConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _keyAsSegmentSupported; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Capabilities.V1.KeyAsSegmentSupported"; 23 | 24 | /// 25 | /// Supports [key-as-segment convention](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_KeyasSegmentConvention) for addressing entities within a collection 26 | /// 27 | /// The value to set 28 | /// 29 | public KeyAsSegmentSupportedConfiguration IsKeyAsSegmentSupported(bool keyAsSegmentSupported) 30 | { 31 | _keyAsSegmentSupported = keyAsSegmentSupported; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _keyAsSegmentSupported.HasValue ? new EdmBooleanConstant(_keyAsSegmentSupported.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/MediaLocationUpdateSupportedConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Stream property supports update of its media edit URL and/or media read URL 16 | /// 17 | public partial class MediaLocationUpdateSupportedConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _mediaLocationUpdateSupported; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Capabilities.V1.MediaLocationUpdateSupported"; 23 | 24 | /// 25 | /// Stream property supports update of its media edit URL and/or media read URL 26 | /// 27 | /// The value to set 28 | /// 29 | public MediaLocationUpdateSupportedConfiguration IsMediaLocationUpdateSupported(bool mediaLocationUpdateSupported) 30 | { 31 | _mediaLocationUpdateSupported = mediaLocationUpdateSupported; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _mediaLocationUpdateSupported.HasValue ? new EdmBooleanConstant(_mediaLocationUpdateSupported.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/NavigationType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Org.OData.Capabilities.V1.NavigationType 16 | /// 17 | public enum NavigationType 18 | { 19 | /// 20 | /// Navigation properties can be recursively navigated 21 | /// 22 | Recursive, 23 | 24 | /// 25 | /// Navigation properties can be navigated to a single level 26 | /// 27 | Single, 28 | 29 | /// 30 | /// Navigation properties are not navigable 31 | /// 32 | None, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/QuerySegmentSupportedConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Supports [passing query options in the request body](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_PassingQueryOptionsintheRequestBody) 16 | /// 17 | public partial class QuerySegmentSupportedConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _querySegmentSupported; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Capabilities.V1.QuerySegmentSupported"; 23 | 24 | /// 25 | /// Supports [passing query options in the request body](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_PassingQueryOptionsintheRequestBody) 26 | /// 27 | /// The value to set 28 | /// 29 | public QuerySegmentSupportedConfiguration IsQuerySegmentSupported(bool querySegmentSupported) 30 | { 31 | _querySegmentSupported = querySegmentSupported; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _querySegmentSupported.HasValue ? new EdmBooleanConstant(_querySegmentSupported.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/SearchExpressions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Org.OData.Capabilities.V1.SearchExpressions 16 | /// 17 | [Flags] 18 | public enum SearchExpressions 19 | { 20 | /// 21 | /// Single search term 22 | /// 23 | none, 24 | 25 | /// 26 | /// Multiple search terms separated by `AND` 27 | /// 28 | AND, 29 | 30 | /// 31 | /// Multiple search terms separated by `OR` 32 | /// 33 | OR, 34 | 35 | /// 36 | /// Search terms preceded by `NOT` 37 | /// 38 | NOT, 39 | 40 | /// 41 | /// Search phrases enclosed in double quotes 42 | /// 43 | phrase, 44 | 45 | /// 46 | /// Precedence grouping of search expressions with parentheses 47 | /// 48 | group, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/SkipSupportedConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Supports $skip 16 | /// 17 | public partial class SkipSupportedConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _skipSupported; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Capabilities.V1.SkipSupported"; 23 | 24 | /// 25 | /// Supports $skip 26 | /// 27 | /// The value to set 28 | /// 29 | public SkipSupportedConfiguration IsSkipSupported(bool skipSupported) 30 | { 31 | _skipSupported = skipSupported; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _skipSupported.HasValue ? new EdmBooleanConstant(_skipSupported.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/SupportedFormatsConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Media types of supported formats, including format parameters 16 | /// 17 | public partial class SupportedFormatsConfiguration : VocabularyTermConfiguration 18 | { 19 | private readonly HashSet _supportedFormats = new HashSet(); 20 | 21 | /// 22 | public override string TermName => "Org.OData.Capabilities.V1.SupportedFormats"; 23 | 24 | /// 25 | /// Media types of supported formats, including format parameters 26 | /// 27 | /// The value(s) to set 28 | /// 29 | public SupportedFormatsConfiguration HasSupportedFormats(params string[] supportedFormats) 30 | { 31 | _supportedFormats.UnionWith(supportedFormats); 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | if (!_supportedFormats.Any()) 39 | { 40 | return null; 41 | } 42 | 43 | var records = _supportedFormats.Select(item => item.ToEdmExpression()); 44 | return new EdmCollectionExpression(records); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/SupportedMetadataFormatsConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Media types of supported formats for $metadata, including format parameters 16 | /// 17 | public partial class SupportedMetadataFormatsConfiguration : VocabularyTermConfiguration 18 | { 19 | private readonly HashSet _supportedMetadataFormats = new HashSet(); 20 | 21 | /// 22 | public override string TermName => "Org.OData.Capabilities.V1.SupportedMetadataFormats"; 23 | 24 | /// 25 | /// Media types of supported formats for $metadata, including format parameters 26 | /// 27 | /// The value(s) to set 28 | /// 29 | public SupportedMetadataFormatsConfiguration HasSupportedMetadataFormats(params string[] supportedMetadataFormats) 30 | { 31 | _supportedMetadataFormats.UnionWith(supportedMetadataFormats); 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | if (!_supportedMetadataFormats.Any()) 39 | { 40 | return null; 41 | } 42 | 43 | var records = _supportedMetadataFormats.Select(item => item.ToEdmExpression()); 44 | return new EdmCollectionExpression(records); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/TopSupportedConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Capabilities.V1 13 | { 14 | /// 15 | /// Supports $top 16 | /// 17 | public partial class TopSupportedConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _topSupported; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Capabilities.V1.TopSupported"; 23 | 24 | /// 25 | /// Supports $top 26 | /// 27 | /// The value to set 28 | /// 29 | public TopSupportedConfiguration IsTopSupported(bool topSupported) 30 | { 31 | _topSupported = topSupported; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _topSupported.HasValue ? new EdmBooleanConstant(_topSupported.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/CapabilitiesNavigationType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder 5 | { 6 | /// 7 | /// Enumerates the navigation type can apply on navigation restrictions. 8 | /// 9 | internal enum CapabilitiesNavigationType 10 | { 11 | /// 12 | /// Navigation properties can be recursively navigated. 13 | /// 14 | Recursive, 15 | 16 | /// 17 | /// Navigation properties can be navigated to a single level. 18 | /// 19 | Single, 20 | 21 | /// 22 | /// Navigation properties are not navigable. 23 | /// 24 | None 25 | } 26 | } -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AcceptableMediaTypesConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// Lists the MIME types acceptable for the annotated entity type marked with HasStream="true" or the annotated stream property 16 | /// 17 | public partial class AcceptableMediaTypesConfiguration : VocabularyTermConfiguration 18 | { 19 | private readonly HashSet _acceptableMediaTypes = new HashSet(); 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.AcceptableMediaTypes"; 23 | 24 | /// 25 | /// Lists the MIME types acceptable for the annotated entity type marked with HasStream="true" or the annotated stream property 26 | /// 27 | /// The value(s) to set 28 | /// 29 | public AcceptableMediaTypesConfiguration HasAcceptableMediaTypes(params string[] acceptableMediaTypes) 30 | { 31 | _acceptableMediaTypes.UnionWith(acceptableMediaTypes); 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | if (!_acceptableMediaTypes.Any()) 39 | { 40 | return null; 41 | } 42 | 43 | var records = _acceptableMediaTypes.Select(item => item.ToEdmExpression()); 44 | return new EdmCollectionExpression(records); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AutoExpandConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// The service will automatically expand this stream or navigation property even if not requested with $expand 16 | /// 17 | public partial class AutoExpandConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _autoExpand; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.AutoExpand"; 23 | 24 | /// 25 | /// The service will automatically expand this stream or navigation property even if not requested with $expand 26 | /// 27 | /// The value to set 28 | /// 29 | public AutoExpandConfiguration IsAutoExpand(bool autoExpand) 30 | { 31 | _autoExpand = autoExpand; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _autoExpand.HasValue ? new EdmBooleanConstant(_autoExpand.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AutoExpandReferencesConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// The service will automatically expand this navigation property as entity references even if not requested with $expand=.../$ref 16 | /// 17 | public partial class AutoExpandReferencesConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _autoExpandReferences; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.AutoExpandReferences"; 23 | 24 | /// 25 | /// The service will automatically expand this navigation property as entity references even if not requested with $expand=.../$ref 26 | /// 27 | /// The value to set 28 | /// 29 | public AutoExpandReferencesConfiguration IsAutoExpandReferences(bool autoExpandReferences) 30 | { 31 | _autoExpandReferences = autoExpandReferences; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _autoExpandReferences.HasValue ? new EdmBooleanConstant(_autoExpandReferences.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ComputedConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// A value for this property is generated on both insert and update 16 | /// 17 | public partial class ComputedConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _computed; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.Computed"; 23 | 24 | /// 25 | /// A value for this property is generated on both insert and update 26 | /// 27 | /// The value to set 28 | /// 29 | public ComputedConfiguration IsComputed(bool computed) 30 | { 31 | _computed = computed; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _computed.HasValue ? new EdmBooleanConstant(_computed.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ComputedDefaultValueConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// A value for this property can be provided by the client on insert and update. If no value is provided on insert, a non-static default value is generated 16 | /// 17 | public partial class ComputedDefaultValueConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _computedDefaultValue; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.ComputedDefaultValue"; 23 | 24 | /// 25 | /// A value for this property can be provided by the client on insert and update. If no value is provided on insert, a non-static default value is generated 26 | /// 27 | /// The value to set 28 | /// 29 | public ComputedDefaultValueConfiguration IsComputedDefaultValue(bool computedDefaultValue) 30 | { 31 | _computedDefaultValue = computedDefaultValue; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _computedDefaultValue.HasValue ? new EdmBooleanConstant(_computedDefaultValue.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ContentIDConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// A unique identifier for nested entities within a request. 16 | /// 17 | public partial class ContentIDConfiguration : VocabularyTermConfiguration 18 | { 19 | private string _contentID; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.ContentID"; 23 | 24 | /// 25 | /// A unique identifier for nested entities within a request. 26 | /// 27 | /// The value to set 28 | /// 29 | public ContentIDConfiguration HasContentID(string contentID) 30 | { 31 | _contentID = contentID; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return new EdmStringConstant(_contentID); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ConventionalIDsConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// Entity-ids follow OData URL conventions 16 | /// 17 | public partial class ConventionalIDsConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _conventionalIDs; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.ConventionalIDs"; 23 | 24 | /// 25 | /// Entity-ids follow OData URL conventions 26 | /// 27 | /// The value to set 28 | /// 29 | public ConventionalIDsConfiguration IsConventionalIDs(bool conventionalIDs) 30 | { 31 | _conventionalIDs = conventionalIDs; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _conventionalIDs.HasValue ? new EdmBooleanConstant(_conventionalIDs.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/DataModificationOperationKind.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// Org.OData.Core.V1.DataModificationOperationKind 16 | /// 17 | public enum DataModificationOperationKind 18 | { 19 | /// 20 | /// Insert new instance 21 | /// 22 | insert, 23 | 24 | /// 25 | /// Update existing instance 26 | /// 27 | update, 28 | 29 | /// 30 | /// Insert new instance or update it if it already exists 31 | /// 32 | upsert, 33 | 34 | /// 35 | /// Delete existing instance 36 | /// 37 | delete, 38 | 39 | /// 40 | /// Invoke action or function 41 | /// 42 | invoke, 43 | 44 | /// 45 | /// Add link between entities 46 | /// 47 | link, 48 | 49 | /// 50 | /// Remove link between entities 51 | /// 52 | unlink, 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/DereferenceableIDsConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// Entity-ids are URLs that locate the identified entity 16 | /// 17 | public partial class DereferenceableIDsConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _dereferenceableIDs; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.DereferenceableIDs"; 23 | 24 | /// 25 | /// Entity-ids are URLs that locate the identified entity 26 | /// 27 | /// The value to set 28 | /// 29 | public DereferenceableIDsConfiguration IsDereferenceableIDs(bool dereferenceableIDs) 30 | { 31 | _dereferenceableIDs = dereferenceableIDs; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _dereferenceableIDs.HasValue ? new EdmBooleanConstant(_dereferenceableIDs.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/DescriptionConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// A brief description of a model element 16 | /// 17 | public partial class DescriptionConfiguration : VocabularyTermConfiguration 18 | { 19 | private string _description; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.Description"; 23 | 24 | /// 25 | /// A brief description of a model element 26 | /// 27 | /// The value to set 28 | /// 29 | public DescriptionConfiguration HasDescription(string description) 30 | { 31 | _description = description; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return new EdmStringConstant(_description); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ImmutableConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// A value for this non-key property can be provided by the client on insert and remains unchanged on update 16 | /// 17 | public partial class ImmutableConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _immutable; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.Immutable"; 23 | 24 | /// 25 | /// A value for this non-key property can be provided by the client on insert and remains unchanged on update 26 | /// 27 | /// The value to set 28 | /// 29 | public ImmutableConfiguration IsImmutable(bool immutable) 30 | { 31 | _immutable = immutable; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _immutable.HasValue ? new EdmBooleanConstant(_immutable.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/IsLanguageDependentConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// Properties and terms annotated with this term are language-dependent 16 | /// 17 | public partial class IsLanguageDependentConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _isLanguageDependent; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.IsLanguageDependent"; 23 | 24 | /// 25 | /// Properties and terms annotated with this term are language-dependent 26 | /// 27 | /// The value to set 28 | /// 29 | public IsLanguageDependentConfiguration IsIsLanguageDependent(bool isLanguageDependent) 30 | { 31 | _isLanguageDependent = isLanguageDependent; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _isLanguageDependent.HasValue ? new EdmBooleanConstant(_isLanguageDependent.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/IsMediaTypeConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// Properties and terms annotated with this term MUST contain a valid MIME type 16 | /// 17 | public partial class IsMediaTypeConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _isMediaType; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.IsMediaType"; 23 | 24 | /// 25 | /// Properties and terms annotated with this term MUST contain a valid MIME type 26 | /// 27 | /// The value to set 28 | /// 29 | public IsMediaTypeConfiguration IsIsMediaType(bool isMediaType) 30 | { 31 | _isMediaType = isMediaType; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _isMediaType.HasValue ? new EdmBooleanConstant(_isMediaType.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/IsURLConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// Properties and terms annotated with this term MUST contain a valid URL 16 | /// 17 | public partial class IsURLConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _isURL; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.IsURL"; 23 | 24 | /// 25 | /// Properties and terms annotated with this term MUST contain a valid URL 26 | /// 27 | /// The value to set 28 | /// 29 | public IsURLConfiguration IsIsURL(bool isURL) 30 | { 31 | _isURL = isURL; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _isURL.HasValue ? new EdmBooleanConstant(_isURL.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/LongDescriptionConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// A lengthy description of a model element 16 | /// 17 | public partial class LongDescriptionConfiguration : VocabularyTermConfiguration 18 | { 19 | private string _longDescription; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.LongDescription"; 23 | 24 | /// 25 | /// A lengthy description of a model element 26 | /// 27 | /// The value to set 28 | /// 29 | public LongDescriptionConfiguration HasLongDescription(string longDescription) 30 | { 31 | _longDescription = longDescription; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return new EdmStringConstant(_longDescription); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/MayImplementConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// A collection of qualified type names outside of the type hierarchy that instances of this type might be addressable as by using a type-cast segment. 16 | /// 17 | public partial class MayImplementConfiguration : VocabularyTermConfiguration 18 | { 19 | private readonly HashSet _mayImplement = new HashSet(); 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.MayImplement"; 23 | 24 | /// 25 | /// A collection of qualified type names outside of the type hierarchy that instances of this type might be addressable as by using a type-cast segment. 26 | /// 27 | /// The value(s) to set 28 | /// 29 | public MayImplementConfiguration HasMayImplement(params string[] mayImplement) 30 | { 31 | _mayImplement.UnionWith(mayImplement); 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | if (!_mayImplement.Any()) 39 | { 40 | return null; 41 | } 42 | 43 | var records = _mayImplement.Select(item => item.ToEdmExpression()); 44 | return new EdmCollectionExpression(records); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/MediaTypeConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// The media type of a binary resource 16 | /// 17 | public partial class MediaTypeConfiguration : VocabularyTermConfiguration 18 | { 19 | private string _mediaType; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.MediaType"; 23 | 24 | /// 25 | /// The media type of a binary resource 26 | /// 27 | /// The value to set 28 | /// 29 | public MediaTypeConfiguration HasMediaType(string mediaType) 30 | { 31 | _mediaType = mediaType; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return new EdmStringConstant(_mediaType); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ODataVersionsConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// A space-separated list of supported versions of the OData Protocol. Note that 4.0 is implied by 4.01 and does not need to be separately listed. 16 | /// 17 | public partial class ODataVersionsConfiguration : VocabularyTermConfiguration 18 | { 19 | private string _oDataVersions; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.ODataVersions"; 23 | 24 | /// 25 | /// A space-separated list of supported versions of the OData Protocol. Note that 4.0 is implied by 4.01 and does not need to be separately listed. 26 | /// 27 | /// The value to set 28 | /// 29 | public ODataVersionsConfiguration HasODataVersions(string oDataVersions) 30 | { 31 | _oDataVersions = oDataVersions; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return new EdmStringConstant(_oDataVersions); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/OrderedConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// Collection has a stable order. Ordered collections of primitive or complex types can be indexed by ordinal. 16 | /// 17 | public partial class OrderedConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _ordered; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.Ordered"; 23 | 24 | /// 25 | /// Collection has a stable order. Ordered collections of primitive or complex types can be indexed by ordinal. 26 | /// 27 | /// The value to set 28 | /// 29 | public OrderedConfiguration IsOrdered(bool ordered) 30 | { 31 | _ordered = ordered; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _ordered.HasValue ? new EdmBooleanConstant(_ordered.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/Permission.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// Org.OData.Core.V1.Permission 16 | /// 17 | [Flags] 18 | public enum Permission 19 | { 20 | /// 21 | /// No permissions 22 | /// 23 | None, 24 | 25 | /// 26 | /// Read permission 27 | /// 28 | Read, 29 | 30 | /// 31 | /// Write permission 32 | /// 33 | Write, 34 | 35 | /// 36 | /// Read and write permission 37 | /// 38 | ReadWrite, 39 | 40 | /// 41 | /// Permission to invoke actions 42 | /// 43 | Invoke, 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/PositionalInsertConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// Items can be inserted at a given ordinal index. 16 | /// 17 | public partial class PositionalInsertConfiguration : VocabularyTermConfiguration 18 | { 19 | private bool? _positionalInsert; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.PositionalInsert"; 23 | 24 | /// 25 | /// Items can be inserted at a given ordinal index. 26 | /// 27 | /// The value to set 28 | /// 29 | public PositionalInsertConfiguration IsPositionalInsert(bool positionalInsert) 30 | { 31 | _positionalInsert = positionalInsert; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return _positionalInsert.HasValue ? new EdmBooleanConstant(_positionalInsert.Value) : null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/RequiresTypeConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// Terms annotated with this term can only be applied to elements that have a type that is identical to or derived from the given type name 16 | /// 17 | public partial class RequiresTypeConfiguration : VocabularyTermConfiguration 18 | { 19 | private string _requiresType; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.RequiresType"; 23 | 24 | /// 25 | /// Terms annotated with this term can only be applied to elements that have a type that is identical to or derived from the given type name 26 | /// 27 | /// The value to set 28 | /// 29 | public RequiresTypeConfiguration HasRequiresType(string requiresType) 30 | { 31 | _requiresType = requiresType; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return new EdmStringConstant(_requiresType); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ResourcePathConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// Resource path for entity container child, can be relative to xml:base and the request URL 16 | /// 17 | public partial class ResourcePathConfiguration : VocabularyTermConfiguration 18 | { 19 | private string _resourcePath; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.ResourcePath"; 23 | 24 | /// 25 | /// Resource path for entity container child, can be relative to xml:base and the request URL 26 | /// 27 | /// The value to set 28 | /// 29 | public ResourcePathConfiguration HasResourcePath(string resourcePath) 30 | { 31 | _resourcePath = resourcePath; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return new EdmStringConstant(_resourcePath); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/RevisionKind.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// Org.OData.Core.V1.RevisionKind 16 | /// 17 | public enum RevisionKind 18 | { 19 | /// 20 | /// Model element was added 21 | /// 22 | Added, 23 | 24 | /// 25 | /// Model element was modified 26 | /// 27 | Modified, 28 | 29 | /// 30 | /// Model element was deprecated 31 | /// 32 | Deprecated, 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/SchemaVersionConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | // This is an auto generated file. Please run the template to modify it. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using Microsoft.OData.Edm; 10 | using Microsoft.OData.Edm.Vocabularies; 11 | 12 | namespace Microsoft.OData.ModelBuilder.Core.V1 13 | { 14 | /// 15 | /// Service-defined value representing the version of the schema. Services MAY use semantic versioning, but clients MUST NOT assume this is the case. 16 | /// 17 | public partial class SchemaVersionConfiguration : VocabularyTermConfiguration 18 | { 19 | private string _schemaVersion; 20 | 21 | /// 22 | public override string TermName => "Org.OData.Core.V1.SchemaVersion"; 23 | 24 | /// 25 | /// Service-defined value representing the version of the schema. Services MAY use semantic versioning, but clients MUST NOT assume this is the case. 26 | /// 27 | /// The value to set 28 | /// 29 | public SchemaVersionConfiguration HasSchemaVersion(string schemaVersion) 30 | { 31 | _schemaVersion = schemaVersion; 32 | return this; 33 | } 34 | 35 | /// 36 | public override IEdmExpression ToEdmExpression() 37 | { 38 | return new EdmStringConstant(_schemaVersion); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/IRecord.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using Microsoft.OData.Edm; 5 | using Microsoft.OData.Edm.Vocabularies; 6 | 7 | namespace Microsoft.OData.ModelBuilder 8 | { 9 | /// 10 | /// Interface for clr types that can be converted into 11 | /// 12 | public interface IRecord 13 | { 14 | /// 15 | /// Convert a clr type to an 16 | /// 17 | /// 18 | IEdmExpression ToEdmExpression(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/IVocabularyTermConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Microsoft.OData.ModelBuilder.Vocabularies 8 | { 9 | /// 10 | /// interface for all vocabulary configuration classes 11 | /// 12 | public interface IVocabularyTermConfiguration 13 | { 14 | /// 15 | /// Vocabulary builders to annotate this 16 | /// 17 | Dictionary VocabularyTermConfigurations { get; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/VocabularyConfigurationsBase.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Microsoft.OData.ModelBuilder.Vocabularies 8 | { 9 | /// 10 | /// Base for all vocabulary configuration classes. 11 | /// 12 | public class VocabularyConfigurationsBase : IVocabularyTermConfiguration 13 | { 14 | /// 15 | /// Vocabulary builders to annotate this 16 | /// 17 | public Dictionary VocabularyTermConfigurations { get; } = new Dictionary(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Microsoft.OData.ModelBuilder/Vocabularies/VocabularyTermConfigurationShortcutsExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Linq; 5 | using Microsoft.OData.ModelBuilder.Capabilities.V1; 6 | 7 | namespace Microsoft.OData.ModelBuilder.Vocabularies 8 | { 9 | /// 10 | /// Shortcuts for common configurations to be extended in here. 11 | /// 12 | public static class VocabularyTermConfigurationShortcutsExtensions 13 | { 14 | /// 15 | /// List of scopes that can provide access to the resource 16 | /// 17 | /// 18 | /// The value(s) to set 19 | /// 20 | public static PermissionTypeConfiguration HasScopes(this PermissionTypeConfiguration permissionTypeConfiguration, params string[] scopeNames) 21 | => permissionTypeConfiguration?.HasScopes(scopeNames.Select(scope => new ScopeTypeConfiguration().HasScope(scope)).ToArray()); 22 | 23 | } 24 | } -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/Annotations/ClrPropertyInfoAnnotationTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using Xunit; 6 | 7 | namespace Microsoft.OData.ModelBuilder.Tests.Annotations 8 | { 9 | public class ClrPropertyInfoAnnotationTest 10 | { 11 | [Fact] 12 | public void Ctor_ThrowsForNullPropertyInfo() 13 | { 14 | Assert.Throws("clrPropertyInfo", 15 | () => new ClrPropertyInfoAnnotation(clrPropertyInfo: null)); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/Annotations/DynamicPropertyDictionaryAnnotationTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Reflection; 6 | using Microsoft.OData.ModelBuilder.Tests.Commons; 7 | using Moq; 8 | using Xunit; 9 | 10 | namespace Microsoft.OData.ModelBuilder.Tests.Annotations 11 | { 12 | public class DynamicPropertyDictionaryAnnotationTest 13 | { 14 | [Fact] 15 | public void Ctor_ThrowsForNullPropertyInfo() 16 | { 17 | ExceptionAssert.ThrowsArgumentNull( 18 | () => new DynamicPropertyDictionaryAnnotation(propertyInfo: null), 19 | "propertyInfo"); 20 | } 21 | 22 | [Fact] 23 | public void Ctor_ThrowsForNotIDictionaryPropretyInfo() 24 | { 25 | // Arrange 26 | Mock propertyInfo = new Mock(); 27 | propertyInfo.Setup(p => p.PropertyType).Returns(typeof(int)); 28 | 29 | // Act & Assert 30 | ExceptionAssert.Throws(() => new DynamicPropertyDictionaryAnnotation( 31 | propertyInfo: propertyInfo.Object), 32 | "Type 'Int32' is not supported as dynamic property annotation. " + 33 | "Referenced property must be of type 'IDictionary'. (Parameter 'propertyInfo')"); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/Commons/MockAssembly.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Reflection; 8 | 9 | namespace Microsoft.OData.ModelBuilder.Tests.Commons 10 | { 11 | public sealed class MockAssembly : Assembly 12 | { 13 | Type[] _types; 14 | 15 | public MockAssembly(params Type[] types) 16 | { 17 | _types = types; 18 | } 19 | 20 | public MockAssembly(params MockType[] types) 21 | { 22 | foreach (var type in types) 23 | { 24 | type.SetupGet(t => t.Assembly).Returns(this); 25 | } 26 | _types = types.Select(t => t.Object).ToArray(); 27 | } 28 | 29 | /// 30 | /// AspNet uses GetTypes as opposed to DefinedTypes() 31 | /// 32 | public override Type[] GetTypes() 33 | { 34 | return _types; 35 | } 36 | 37 | /// 38 | /// AspNetCore uses DefinedTypes as opposed to GetTypes() 39 | /// 40 | public override IEnumerable DefinedTypes 41 | { 42 | get { return _types.AsEnumerable().Select(a => a.GetTypeInfo()); } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/Commons/MockAssemblyResolver.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Reflection; 8 | 9 | namespace Microsoft.OData.ModelBuilder.Tests.Commons 10 | { 11 | public sealed class MockAssemblyResolver : IAssemblyResolver 12 | { 13 | private Assembly[] _mockAssemblies; 14 | 15 | public MockAssemblyResolver(params Assembly[] assemblies) 16 | { 17 | _mockAssemblies = assemblies; 18 | } 19 | 20 | public IEnumerable Assemblies 21 | { 22 | get 23 | { 24 | if (_mockAssemblies != null) 25 | { 26 | return _mockAssemblies; 27 | } 28 | 29 | return AppDomain.CurrentDomain.GetAssemblies().Distinct(); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/Commons/MockPropertyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Reflection; 6 | using Moq; 7 | 8 | namespace Microsoft.OData.ModelBuilder.Tests.Commons 9 | { 10 | public sealed class MockPropertyInfo : Mock 11 | { 12 | private readonly Mock _mockGetMethod = new Mock(); 13 | private readonly Mock _mockSetMethod = new Mock(); 14 | 15 | public static implicit operator PropertyInfo(MockPropertyInfo mockPropertyInfo) 16 | { 17 | return mockPropertyInfo.Object; 18 | } 19 | 20 | public MockPropertyInfo() 21 | : this(typeof(object), "P") 22 | { 23 | } 24 | 25 | public MockPropertyInfo(Type propertyType, string propertyName) 26 | { 27 | SetupGet(p => p.DeclaringType).Returns(typeof(object)); 28 | SetupGet(p => p.ReflectedType).Returns(typeof(object)); 29 | SetupGet(p => p.Name).Returns(propertyName); 30 | SetupGet(p => p.PropertyType).Returns(propertyType); 31 | SetupGet(p => p.CanRead).Returns(true); 32 | SetupGet(p => p.CanWrite).Returns(true); 33 | Setup(p => p.GetGetMethod(It.IsAny())).Returns(_mockGetMethod.Object); 34 | Setup(p => p.GetSetMethod(It.IsAny())).Returns(_mockSetMethod.Object); 35 | Setup(p => p.Equals(It.IsAny())).Returns(p => ReferenceEquals(Object, p)); 36 | 37 | _mockGetMethod.SetupGet(m => m.Attributes).Returns(MethodAttributes.Public); 38 | } 39 | 40 | public MockPropertyInfo Abstract() 41 | { 42 | _mockGetMethod.SetupGet(m => m.Attributes) 43 | .Returns(_mockGetMethod.Object.Attributes | MethodAttributes.Abstract); 44 | 45 | return this; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/Commons/ODataModelBuilderMocks.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using Microsoft.OData.Edm; 5 | using Moq; 6 | using System; 7 | 8 | namespace Microsoft.OData.ModelBuilder.Tests.Commons 9 | { 10 | public static class ODataModelBuilderMocks 11 | { 12 | // Creates a mock of an ODataModelBuilder or any subclass of it that disables model validation 13 | // in order to reduce verbosity on tests. 14 | public static ODataModelBuilder GetModelBuilderMock() 15 | { 16 | Mock mock = new Mock(); 17 | mock.Setup(b => b.ValidateModel(It.IsAny())).Callback(() => { }); 18 | mock.CallBase = true; 19 | return mock.Object; 20 | } 21 | 22 | public static ODataConventionModelBuilder GetConventionModelBuilder() 23 | { 24 | Mock mock = new Mock(); 25 | mock.Setup(b => b.ValidateModel(It.IsAny())).Callback(() => { }); 26 | mock.CallBase = true; 27 | return mock.Object; 28 | } 29 | 30 | public static ODataConventionModelBuilder MockConventionModelBuilder(params Type[] types) 31 | { 32 | MockAssembly assembly = new MockAssembly(types); 33 | MockAssemblyResolver resolver = new MockAssemblyResolver(assembly); 34 | Mock mock = new Mock(resolver); 35 | mock.Setup(b => b.ValidateModel(It.IsAny())).Callback(() => { }); 36 | mock.CallBase = true; 37 | return mock.Object; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/Containers/BindingCustomerModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Tests.Containers 7 | { 8 | public class BindingCustomer 9 | { 10 | public int Id { get; set; } 11 | 12 | public BindingAddress Location { get; set; } 13 | 14 | public BindingAddress Address { get; set; } 15 | 16 | public IList Addresses { get; set; } 17 | } 18 | 19 | public class BindingVipCustomer : BindingCustomer 20 | { 21 | public BindingAddress VipLocation { get; set; } 22 | 23 | public IList VipAddresses { get; set; } 24 | } 25 | 26 | public class BindingCity 27 | { 28 | public int Id { get; set; } 29 | } 30 | 31 | public class BindingAddress 32 | { 33 | public BindingCity City { get; set; } 34 | 35 | public IList Cities { get; set; } 36 | } 37 | 38 | public class BindingUsAddress : BindingAddress 39 | { 40 | public BindingCity UsCity { get; set; } 41 | 42 | public ICollection UsCities { get; set; } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/Containers/BindingPathHelperTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | using System.Reflection; 6 | using Microsoft.OData.ModelBuilder.Tests.Commons; 7 | using Xunit; 8 | 9 | namespace Microsoft.OData.ModelBuilder.Tests.Containers 10 | { 11 | public class BindingPathHelperTest 12 | { 13 | [Fact] 14 | public void ConvertBindingPath_Throws() 15 | { 16 | // Arrange 17 | IList path = null; 18 | 19 | // Act & Assert 20 | ExceptionAssert.ThrowsArgumentNull(() => path.ConvertBindingPath(), "bindingPath"); 21 | } 22 | 23 | [Fact] 24 | public void ConvertBindingPath_Returns() 25 | { 26 | // Arrange 27 | MockType type = new MockType("MockType"); 28 | MockPropertyInfo propertyInfo = new MockPropertyInfo(typeof(object), "propertyName"); 29 | 30 | // Act 31 | IList path = new List { type.Object, propertyInfo.Object }; 32 | 33 | // Assert 34 | Assert.Equal("DefaultNamespace.MockType/propertyName", path.ConvertBindingPath()); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/Microsoft.OData.ModelBuilder.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | Microsoft.OData.ModelBuilder.Tests 6 | Microsoft.OData.ModelBuilder.Tests 7 | 8 | 9 | false 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/Operations/BindingParameterConfigurationTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using Xunit; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Tests.Operations 7 | { 8 | public class BindingParameterConfigurationTest 9 | { 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/Property/UntypedPropertyConfigurationTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using Microsoft.OData.ModelBuilder.Tests.Commons; 5 | using Moq; 6 | using Xunit; 7 | 8 | namespace Microsoft.OData.ModelBuilder.Tests.Property 9 | { 10 | public class UntypedPropertyConfigurationTest 11 | { 12 | [Fact] 13 | public void Ctor_Throws_ArgumentNull_Property() 14 | { 15 | // Arrange & Act & Assert 16 | ExceptionAssert.ThrowsArgumentNull( 17 | () => new UntypedPropertyConfiguration(property: null, declaringType: new EntityTypeConfiguration()), 18 | "property"); 19 | } 20 | 21 | [Fact] 22 | public void Ctor_Throws_ArgumentMustBeUntypedProperty_Property() 23 | { 24 | // Arrange & Act 25 | MockPropertyInfo propertyInfo = new MockPropertyInfo(typeof(int), "data"); 26 | 27 | // Assert 28 | ExceptionAssert.ThrowsArgument( 29 | () => new UntypedPropertyConfiguration(propertyInfo, declaringType: new EntityTypeConfiguration()), 30 | "property", 31 | "The property 'data' on type 'System.Object' must be a System.Object property"); 32 | } 33 | 34 | 35 | [Fact] 36 | public void Property_DeclaringType_Returns_DeclaredType() 37 | { 38 | // Arrange 39 | MockPropertyInfo propertyInfo = new MockPropertyInfo(typeof(object), "data"); 40 | Mock mockDeclaringType = new Mock(); 41 | 42 | // Act 43 | UntypedPropertyConfiguration navigationProperty = new UntypedPropertyConfiguration(propertyInfo, mockDeclaringType.Object); 44 | 45 | // Assert 46 | Assert.Equal(mockDeclaringType.Object, navigationProperty.DeclaringType); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/Address.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 5 | { 6 | public class Address 7 | { 8 | public int HouseNumber { get; set; } 9 | public string Street { get; set; } 10 | public string City { get; set; } 11 | public string State { get; set; } 12 | public ZipCode ZipCode { get; set; } 13 | public string IgnoreThis { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/Client.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 7 | { 8 | public class Client 9 | { 10 | public int ID { get; set; } 11 | 12 | public string Name { get; set; } 13 | 14 | public virtual ICollection MyOrders { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/Color.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 7 | { 8 | [Flags] 9 | public enum Color 10 | { 11 | Red = 1, 12 | Green = 2, 13 | Blue = 4 14 | } 15 | } -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/Company.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 7 | { 8 | public class Company 9 | { 10 | public int CompanyId { get; set; } 11 | public string CompanyName { get; set; } 12 | public string Website { get; set; } 13 | public Address HeadQuarterAddress { get; set; } 14 | [Singleton] 15 | public Employee CEO { get; set; } 16 | public int CEOID { get; set; } 17 | public List ComplanyEmployees { get; set; } 18 | public List Customers { get; set; } 19 | public List
Subsidiaries { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/Customer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 8 | { 9 | public class Customer 10 | { 11 | public int CustomerId { get; set; } 12 | public string Name { get; set; } 13 | public string City { get; set; } 14 | public Address Address { get; set; } 15 | public Address WorkAddress { get; set; } 16 | public string Website { get; set; } 17 | public string ShareSymbol { get; set; } 18 | public Decimal? SharePrice { get; set; } 19 | public Company Company { get; set; } 20 | public List Orders { get; set; } 21 | public List Aliases { get; set; } 22 | public List
Addresses { get; set; } 23 | public Dictionary DynamicProperties { get; set; } 24 | public DateTimeOffset? StartDate { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/DateTimeModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 8 | { 9 | public class DateTimeModel 10 | { 11 | public int Id { get; set; } 12 | 13 | public DateTime BirthdayA { get; set; } 14 | 15 | public DateTime? BirthdayB { get; set; } 16 | 17 | public IList BirthdayC { get; set; } 18 | 19 | public IList BirthdayD { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/Employee.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 8 | { 9 | public class Employee 10 | { 11 | public int EmployeeID { get; set; } 12 | public string EmployeeName { get; set; } 13 | public Decimal BaseSalary { get; set; } 14 | public DateTimeOffset Birthday { get; set; } 15 | public IList IsCeoOf { get; set; } 16 | public int WorkCompanyId { get; set; } 17 | public Company WorkCompany { get; set; } 18 | [Singleton] 19 | public Employee Boss { get; set; } 20 | public Address HomeAddress { get; set; } 21 | public IList DirectReports { get; set; } 22 | } 23 | 24 | public class Manager : Employee 25 | { 26 | public Decimal ExtraDraw; 27 | public Address ExtraOffice { get; set; } 28 | } 29 | 30 | public class Engineer : Employee 31 | { 32 | public int Level { get; set; } 33 | public Decimal YearEndBonus { get; set; } 34 | } 35 | 36 | public class SalesPerson : Employee 37 | { 38 | public Decimal Bonus { get; set; } 39 | public IList Customers { get; set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/EnumModels.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 7 | { 8 | public class EnumModel 9 | { 10 | public int Id { get; set; } 11 | public SimpleEnum Simple { get; set; } 12 | public SimpleEnum? SimpleNullable { get; set; } 13 | public LongEnum Long { get; set; } 14 | public ByteEnum Byte { get; set; } 15 | public SByteEnum SByte { get; set; } 16 | public ShortEnum Short { get; set; } 17 | public UShortEnum UShort { get; set; } 18 | public UIntEnum UInt { get; set; } 19 | public FlagsEnum Flag { get; set; } 20 | public FlagsEnum? FlagNullable { get; set; } 21 | } 22 | 23 | public enum UShortEnum : ushort 24 | { 25 | FirstUShort, 26 | SecondUShort, 27 | ThirdUShort 28 | } 29 | 30 | public enum UIntEnum : uint 31 | { 32 | FirstUInt, 33 | SecondUInt, 34 | ThirdUInt 35 | } 36 | 37 | public enum SByteEnum : sbyte 38 | { 39 | FirstSByte, 40 | SecondSByte, 41 | ThirdSByte 42 | } 43 | 44 | public enum ByteEnum : byte 45 | { 46 | FirstByte, 47 | SecondByte, 48 | ThirdByte 49 | } 50 | 51 | public enum SimpleEnum 52 | { 53 | First, 54 | Second, 55 | Third, 56 | Fourth 57 | } 58 | 59 | public enum ShortEnum : short 60 | { 61 | FirstShort, 62 | SecondShort, 63 | ThirdShort 64 | } 65 | 66 | public enum LongEnum : long 67 | { 68 | FirstLong, 69 | SecondLong, 70 | ThirdLong, 71 | FourthLong 72 | } 73 | 74 | [Flags] 75 | public enum FlagsEnum 76 | { 77 | One = 0x1, 78 | Two = 0x2, 79 | Four = 0x4 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/Gift.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 5 | { 6 | public class Gift 7 | { 8 | public int ID { get; set; } 9 | 10 | public int orderId { get; set; } 11 | 12 | public string Name { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/INameAndIdContainer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 5 | { 6 | /// 7 | /// Tagging interface to assist comparing instances of these types. 8 | /// 9 | public interface INameAndIdContainer 10 | { 11 | string Name { get; set; } 12 | 13 | int Id { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/ModelAlias.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Runtime.Serialization; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 7 | { 8 | [DataContract(Namespace = "com.contoso", Name = "ModelAlias2")] 9 | public class ModelAlias 10 | { 11 | [DataMember] 12 | public int Id { get; set; } 13 | 14 | [DataMember] 15 | public string FirstName { get; set; } 16 | } 17 | 18 | [DataContract(Namespace = "com.contoso", Name = "PropertyAlias2")] 19 | public class PropertyAlias 20 | { 21 | [DataMember] 22 | public int Id { get; set; } 23 | 24 | [DataMember(Name = "FirstNameAlias")] 25 | public string FirstName { get; set; } 26 | 27 | public int Points { get; set; } 28 | } 29 | 30 | [DataContract(Namespace = "com.contoso", Name = "PropertyAliasDerived2")] 31 | public class PropertyAliasDerived : PropertyAlias 32 | { 33 | [DataMember(Name = "LastNameAlias")] 34 | public string LastName { get; set; } 35 | 36 | public int Age { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/MyOrder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | using System.ComponentModel.DataAnnotations; 6 | 7 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 8 | { 9 | public class MyOrder 10 | { 11 | public int ID { get; set; } 12 | 13 | public string Name { get; set; } 14 | 15 | [Contained] 16 | public virtual ICollection OrderLines { get; set; } 17 | 18 | [Required] 19 | [Contained] 20 | public virtual OrderHeader OrderHeader { get; set; } 21 | 22 | [Contained] 23 | public virtual OrderCancellation OrderCancellation { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/MySpecialOrder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 5 | { 6 | public class MySpecialOrder : MyOrder 7 | { 8 | public bool IsGift { get; set; } 9 | 10 | [Contained] 11 | public virtual Gift Gift { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/NonNullable/Address.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels.NonNullable 5 | { 6 | #nullable enable 7 | // 8 | // All of the properties in this class will be set to NonNullable through the NullableContextAttribute 9 | // 10 | // NullableContextAttribute{1} 11 | public class Address 12 | { 13 | public int HouseNumber { get; set; } 14 | public string Street { get; set; } = string.Empty; 15 | public string City { get; set; } = string.Empty; 16 | public string State { get; set; } = string.Empty; 17 | public ZipCode ZipCode { get; set; } = new ZipCode(); 18 | public string IgnoreThis { get; set; } = "IgnoreThis"; 19 | } 20 | #nullable restore 21 | } 22 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/NonNullable/Company.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels.NonNullable 7 | { 8 | #nullable enable 9 | // 10 | // Most of the properties in this class will be set to NonNullable through the NullableContextAttribute 11 | // Website Nullable by annotation 12 | // Subsidiaries Nullable by annotation 13 | // 14 | // NullableContextAttribute{1} 15 | public class Company 16 | { 17 | public int CompanyId { get; set; } 18 | public string CompanyName { get; set; } = string.Empty; 19 | // NullableAttribute{2} 20 | public string? Website { get; set; } 21 | public Address HeadQuarterAddress { get; set; } = new Address(); 22 | [Singleton] 23 | public Employee CEO { get; set; } = new Employee(); 24 | public int CEOID { get; set; } 25 | public List CompanyEmployees { get; set; } = new List(); 26 | public List Customers { get; set; } = new List(); 27 | // NullableAttribute{2,1} 28 | public List
? Subsidiaries { get; set; } 29 | } 30 | #nullable restore 31 | } 32 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/NonNullable/Customer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels.NonNullable 8 | { 9 | #nullable enable 10 | // 11 | // Most of the properties in this class will be set to NonNullable through the NullableContextAttribute 12 | // SharePrice Nullable by annotation 13 | // StartDate Nullable by annotation 14 | // 15 | // NullableContextAttribute{1} 16 | public class Customer 17 | { 18 | public int CustomerId { get; set; } 19 | public string Name { get; set; } = string.Empty; 20 | public string City { get; set; } = string.Empty; 21 | public Address Address { get; set; } = new Address(); 22 | public Address WorkAddress { get; set; } = new Address(); 23 | public string Website { get; set; } = string.Empty; 24 | public string ShareSymbol { get; set; } = string.Empty; 25 | public Decimal? SharePrice { get; set; } 26 | public Company Company { get; set; } = new Company(); 27 | public List Orders { get; set; } = new List(); 28 | public List Aliases { get; set; } = new List(); 29 | public List
Addresses { get; set; } = new List
(); 30 | public Dictionary DynamicProperties { get; set; } = new Dictionary(); 31 | public DateTimeOffset? StartDate { get; set; } 32 | } 33 | #nullable restore 34 | } 35 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/NonNullable/Order.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels.NonNullable 7 | { 8 | // 9 | // Most of the properties in this class will be set to NonNullable through the NullableContextAttribute 10 | // DeliveryDate Nullable by annotation 11 | // 12 | // NullableContextAttribute{1} 13 | public class Order 14 | { 15 | public int OrderId { get; set; } 16 | public Customer Customer { get; set; } 17 | public Decimal Cost { get; set; } 18 | public Decimal Price { get; set; } 19 | public DateTimeOffset OrderDate { get; set; } 20 | public DateTimeOffset? DeliveryDate { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/NonNullable/ZipCode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels.NonNullable 5 | { 6 | #nullable enable 7 | // 8 | // Most of the properties in this class will be set to NonNullable through the NullableContextAttribute 9 | // Part2 Nullable by annotation 10 | // 11 | // NullableContextAttribute{1} 12 | public class ZipCode 13 | { 14 | public string Part1 { get; set; } = string.Empty; 15 | // NullableAttribute{2} 16 | public string? Part2 { get; set; } 17 | } 18 | 19 | // 20 | // Most of the properties in this class will be set to NonNullable through the NullableContextAttribute 21 | // RecursiveZipCode Nullable by annotation 22 | // 23 | // NullableContextAttribute{1} 24 | public class RecursiveZipCode 25 | { 26 | public string Part1 { get; set; } = string.Empty; 27 | public string Part2 { get; set; } = string.Empty; 28 | public RecursiveZipCode? Recursive { get; set; } 29 | } 30 | #nullable restore 31 | } 32 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/ODataModelBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 5 | { 6 | public static class ODataModelBuilderExtensions 7 | { 8 | public static ODataModelBuilder Add_Color_EnumType(this ODataModelBuilder builder) 9 | { 10 | var color = builder.EnumType(); 11 | color.Member(Color.Red); 12 | color.Member(Color.Green); 13 | color.Member(Color.Blue); 14 | return builder; 15 | } 16 | 17 | public static ODataModelBuilder Add_SimpleEnum_EnumType(this ODataModelBuilder builder) 18 | { 19 | var simpleEnum = builder.EnumType(); 20 | simpleEnum.Member(SimpleEnum.First); 21 | simpleEnum.Member(SimpleEnum.Second); 22 | simpleEnum.Member(SimpleEnum.Third); 23 | return builder; 24 | } 25 | 26 | public static ODataModelBuilder Add_FlagsEnum_EnumType(this ODataModelBuilder builder) 27 | { 28 | var flagsEnum = builder.EnumType(); 29 | flagsEnum.Member(FlagsEnum.One); 30 | flagsEnum.Member(FlagsEnum.Two); 31 | flagsEnum.Member(FlagsEnum.Four); 32 | return builder; 33 | } 34 | 35 | public static ODataModelBuilder Add_LongEnum_EnumType(this ODataModelBuilder builder) 36 | { 37 | var longEnum = builder.EnumType(); 38 | longEnum.Member(LongEnum.FirstLong); 39 | longEnum.Member(LongEnum.SecondLong); 40 | longEnum.Member(LongEnum.ThirdLong); 41 | return builder; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/Order.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 7 | { 8 | public class Order 9 | { 10 | public int OrderId { get; set; } 11 | public Customer Customer { get; set; } 12 | public Decimal Cost { get; set; } 13 | public Decimal Price { get; set; } 14 | public DateTimeOffset OrderDate { get; set; } 15 | public DateTimeOffset? DeliveryDate { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/OrderCancellation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 5 | { 6 | public class OrderCancellation 7 | { 8 | public int ID { get; set; } 9 | 10 | public string Name { get; set; } 11 | 12 | public int OrderId { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/OrderHeader.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 5 | { 6 | public class OrderHeader 7 | { 8 | public int ID { get; set; } 9 | 10 | public string Name { get; set; } 11 | 12 | public int OrderId { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/OrderLine.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 5 | { 6 | public class OrderLine 7 | { 8 | public int ID { get; set; } 9 | 10 | public string Name { get; set; } 11 | 12 | public int OrderId { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/RecursiveModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using System.ComponentModel.DataAnnotations; 6 | 7 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 8 | { 9 | public class RecursivePropertyContainer 10 | { 11 | public Guid Id { get; set; } 12 | 13 | public GenericSurrogate Item { get; set; } 14 | } 15 | 16 | public abstract class GenericSurrogate 17 | { 18 | } 19 | 20 | public class MyExpression : GenericSurrogate 21 | { 22 | public GenericSurrogate Item { get; set; } 23 | } 24 | 25 | public class Parent 26 | { 27 | public Child OnlyChild { get; set; } 28 | } 29 | 30 | public class Child : Parent 31 | { 32 | public Parent FavoriteParent { get; set; } 33 | 34 | public Car Car { get; set; } 35 | } 36 | 37 | public class Person 38 | { 39 | [Key] 40 | public string Name { get; set; } 41 | 42 | public Parent ResponsibleGuardian { get; set; } 43 | } 44 | 45 | public class CountryDetails 46 | { 47 | [Key] 48 | public int ID { get; set; } 49 | 50 | public string Name { get; set; } 51 | } 52 | 53 | public class RecursiveAddress 54 | { 55 | public string Street { get; set; } 56 | 57 | public string City { get; set; } 58 | 59 | // Navigation property 60 | public CountryDetails CountryDetails { get; set; } 61 | 62 | // Recursive reference 63 | public RecursiveAddress PreviousAddress { get; set; } 64 | } 65 | 66 | public class Organization 67 | { 68 | [Key] 69 | public string Name { get; set; } 70 | 71 | public RecursiveAddress HeadquartersAddress { get; set; } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/SpecialOrderLine.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 5 | { 6 | public class SpecialOrderLine : OrderLine 7 | { 8 | public string MoonCake { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/WorkItem.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 5 | { 6 | public class WorkItem 7 | { 8 | //Automatically is made Key 9 | public int ID { get; set; } 10 | 11 | public int EmployeeID { get; set; } 12 | 13 | public bool IsCompleted { get; set; } 14 | 15 | public float NumberOfHours { get; set; } 16 | 17 | public int Field; 18 | } 19 | 20 | // Used as a type on which keys can be explicitly set 21 | public class DerivedWorkItem : WorkItem 22 | { 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/TestModels/ZipCode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | namespace Microsoft.OData.ModelBuilder.Tests.TestModels 5 | { 6 | public class ZipCode 7 | { 8 | public string Part1 { get; set; } 9 | public string Part2 { get; set; } 10 | } 11 | 12 | public class RecursiveZipCode 13 | { 14 | public string Part1 { get; set; } 15 | public string Part2 { get; set; } 16 | public RecursiveZipCode Recursive { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/Types/ComplexTypeConfigurationTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System; 5 | using Microsoft.OData.ModelBuilder.Tests.Commons; 6 | using Moq; 7 | using Xunit; 8 | 9 | namespace Microsoft.OData.ModelBuilder.Tests.Types 10 | { 11 | public class ComplexTypeConfigurationTest 12 | { 13 | [Theory] 14 | [InlineData(typeof(DateTime))] 15 | [InlineData(typeof(DateTime?))] 16 | public void Ctor_DoesnotThrows_IfPropertyIsDateTime(Type type) 17 | { 18 | Exception ex = Record.Exception(() => new ComplexTypeConfiguration(Mock.Of(), type)); 19 | Assert.Null(ex); 20 | 21 | ExceptionAssert.DoesNotThrow(() => new ComplexTypeConfiguration(Mock.Of(), type)); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/Types/RecursiveComplexTypesModels.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace Microsoft.OData.ModelBuilder.Tests.Types 7 | { 8 | // Scenario 1: Direct reference (complex type points to itself) 9 | public class RecursiveAddress 10 | { 11 | public string Street { get; set; } 12 | 13 | public string City { get; set; } 14 | 15 | public string Country { get; set; } 16 | 17 | public RecursiveAddress PreviousAddress { get; set; } 18 | } 19 | 20 | // Scenario 2: Collection (complex type points to itself via a collection) 21 | public class Field 22 | { 23 | public string Name { get; set; } 24 | 25 | public string DataType { get; set; } 26 | 27 | public List SubFields { get; set; } 28 | } 29 | 30 | // Scenario 3: Composition (complex type points to itself via indirect recursion) 31 | public class RecursiveCustomer 32 | { 33 | public string Name { get; set; } 34 | 35 | public List Accounts { get; set; } 36 | } 37 | 38 | public class Account 39 | { 40 | public int Number { get; set; } 41 | 42 | public RecursiveCustomer Owner { get; set; } 43 | } 44 | 45 | // Scenario 4: Inheritance (complex type has sub-type that points back to the base type via a collection) 46 | public class File 47 | { 48 | public string Name { get; set; } 49 | 50 | public int Size { get; set; } 51 | } 52 | 53 | public class Directory : File 54 | { 55 | public List Files { get; set; } 56 | } 57 | 58 | // Scenario 5: Hybrid of mutual recursion and inheritance. 59 | public class Base 60 | { 61 | public Derived Derived { get; set; } 62 | } 63 | 64 | public class Derived : Base 65 | { 66 | public Base Base { get; set; } 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /test/Microsoft.OData.ModelBuilder.Tests/Types/StructuralTypeConfigurationOfTStructuralTypeTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. See License.txt in the project root for license information. 3 | 4 | using Microsoft.OData.ModelBuilder.Tests.Commons; 5 | using Moq; 6 | using Xunit; 7 | 8 | namespace Microsoft.OData.ModelBuilder.Tests.Types 9 | { 10 | public class StructuralTypeConfigurationOfTStructuralTypeTest 11 | { 12 | private StructuralTypeConfiguration _configuration; 13 | private string _name = "name"; 14 | private string _namespace = "com.contoso"; 15 | 16 | public StructuralTypeConfigurationOfTStructuralTypeTest() 17 | { 18 | Mock mockConfig = new Mock { CallBase = true }; 19 | mockConfig.Object.Name = "Name"; 20 | mockConfig.Object.Namespace = "Namespace"; 21 | 22 | Mock> mockGenericConfig = 23 | new Mock>(mockConfig.Object) { CallBase = true }; 24 | _configuration = mockGenericConfig.Object; 25 | } 26 | 27 | [Fact] 28 | public void Property_Name_RoundTrips() 29 | { 30 | ReflectionAssert.Property(_configuration, c => c.Name, "Name", allowNull: false, roundTripTestValue: _name); 31 | } 32 | 33 | [Fact] 34 | public void Property_Namespace_RoundTrips() 35 | { 36 | ReflectionAssert.Property(_configuration, c => c.Namespace, "Namespace", allowNull: false, roundTripTestValue: _namespace); 37 | } 38 | 39 | [Fact] 40 | public void Property_FullName() 41 | { 42 | Assert.Equal("Namespace.Name", _configuration.FullName); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tools/35MSSharedLib1024.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OData/ModelBuilder/f3e39bcf3320aacf9cc475caa39a1fc9156da125/tools/35MSSharedLib1024.snk --------------------------------------------------------------------------------