├── .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