From a9c0504c5084221b4a1a3a4025a9f1537f621dc2 Mon Sep 17 00:00:00 2001 From: Brecht Debaere Date: Sat, 23 Feb 2019 18:30:40 +0100 Subject: [PATCH 1/3] Add insert, update, delete restrictions based on https://www.odata.org/blog/introducing-a-capabilities-vocabulary/ --- .../CapabilitiesVocabularyConstants.cs | 33 +++++ .../CapabilitiesVocabularyExtensionMethods.cs | 119 ++++++++++++++++++ .../Builder/EdmModelHelperMethods.cs | 100 +++++++++++++++ .../Builder/NavigationSourceConfiguration.cs | 69 ++++++++++ ...igationSourceConfigurationOfTEntityType.cs | 54 ++++++++ .../Builder/PropertyConfiguration.cs | 69 ++++++++++ 6 files changed, 444 insertions(+) diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyConstants.cs b/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyConstants.cs index 0a4f19ad9f..9e1c0b7b56 100644 --- a/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyConstants.cs +++ b/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyConstants.cs @@ -73,5 +73,38 @@ internal static class CapabilitiesVocabularyConstants /// Property NonExpandableProperties of Org.OData.Capabilities.V1.ExpandRestrictions public const string ExpandRestrictionsNonExpandableProperties = "NonExpandableProperties"; + + /// Org.OData.Capabilities.V1.InsertRestrictions + public const string InsertRestrictions = "Org.OData.Capabilities.V1.InsertRestrictions"; + + /// Property Insertable of Org.OData.Capabilities.V1.InsertRestrictions + public const string InsertRestrictionsInsertable = "Insertable"; + + /// Property NonInsertableProperties of Org.OData.Capabilities.V1.InsertRestrictions + public const string InsertRestrictionsNonInsertableProperties = "NonInsertableProperties"; + + /// Property NonInsertableNavigationProperties of Org.OData.Capabilities.V1.InsertRestrictions + public const string InsertRestrictionsNonInsertableNavigationProperties = "NonInsertableNavigationProperties"; + + /// Org.OData.Capabilities.V1.UpdateRestrictions + public const string UpdateRestrictions = "Org.OData.Capabilities.V1.UpdateRestrictions"; + + /// Property Updatable of Org.OData.Capabilities.V1.UpdateRestrictions + public const string UpdateRestrictionsUpdatable = "Updatable"; + + /// Property NonUpdatableProperties of Org.OData.Capabilities.V1.UpdateRestrictions + public const string UpdateRestrictionsNonUpdatableProperties = "NonUpdatableProperties"; + + /// Property NonUpdatableNavigationProperties of Org.OData.Capabilities.V1.UpdateRestrictions + public const string UpdateRestrictionsNonUpdatableNavigationProperties = "NonUpdatableNavigationProperties"; + + /// Org.OData.Capabilities.V1.DeleteRestrictions + public const string DeleteRestrictions = "Org.OData.Capabilities.V1.DeleteRestrictions"; + + /// Property Deletable of Org.OData.Capabilities.V1.DeleteRestrictions + public const string DeleteRestrictionsDeletable = "Deletable"; + + /// Property NonDeletableNavigationProperties of Org.OData.Capabilities.V1.DeleteRestrictions + public const string DeleteRestrictionsNonDeletableNavigationProperties = "NonDeletableNavigationProperties"; } } diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyExtensionMethods.cs b/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyExtensionMethods.cs index df75bb3867..df04173ee9 100644 --- a/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyExtensionMethods.cs +++ b/src/Microsoft.AspNet.OData.Shared/Builder/CapabilitiesVocabularyExtensionMethods.cs @@ -249,6 +249,125 @@ public static void SetExpandRestrictionsAnnotation(this EdmModel model, IEdmEnti model.SetVocabularyAnnotation(target, properties, CapabilitiesVocabularyConstants.ExpandRestrictions); } + /// + /// Set Org.OData.Capabilities.V1.InsertRestrictions to target. + /// + /// The model referenced to. + /// The target entity set to set the inline annotation. + /// This entity set can be inserted. + /// These properties SHOULD be omitted from POST requests because the server will ignore their values. + /// These navigation properties do not allow InsertLink requests. + public static void SetInsertRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target, bool isInsertable, + IEnumerable nonInsertableProperties, + IEnumerable nonInsertableNavigationProperties) + { + if (model == null) + { + throw Error.ArgumentNull("model"); + } + + if (target == null) + { + throw Error.ArgumentNull("target"); + } + + nonInsertableProperties = nonInsertableProperties ?? EmptyStructuralProperties; + nonInsertableNavigationProperties = nonInsertableNavigationProperties ?? EmptyNavigationProperties; + + IList properties = new List + { + new EdmPropertyConstructor(CapabilitiesVocabularyConstants.InsertRestrictionsInsertable, + new EdmBooleanConstant(isInsertable)), + + new EdmPropertyConstructor(CapabilitiesVocabularyConstants.InsertRestrictionsNonInsertableProperties, + new EdmCollectionExpression( + nonInsertableProperties.Select(p => new EdmPropertyPathExpression(p.Name)).ToArray())), + + new EdmPropertyConstructor(CapabilitiesVocabularyConstants.InsertRestrictionsNonInsertableNavigationProperties, + new EdmCollectionExpression( + nonInsertableNavigationProperties.Select(p => new EdmNavigationPropertyPathExpression(p.Name)).ToArray())) + }; + + model.SetVocabularyAnnotation(target, properties, CapabilitiesVocabularyConstants.InsertRestrictions); + } + + /// + /// Set Org.OData.Capabilities.V1.UpdateRestrictions to target. + /// + /// The model referenced to. + /// The target entity set to set the inline annotation. + /// This entity set can be updated. + /// These properties SHOULD be omitted from PUT or PATCH requests because the server will ignore their values.These properties do not allow UpdateValue and DeleteValue requests. + /// These navigation properties do not allow UpdateLink requests. + public static void SetUpdateRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target, bool isUpdatable, + IEnumerable nonUpdatableProperties, + IEnumerable nonUpdatableNavigationProperties) + { + if (model == null) + { + throw Error.ArgumentNull("model"); + } + + if (target == null) + { + throw Error.ArgumentNull("target"); + } + + nonUpdatableProperties = nonUpdatableProperties ?? EmptyStructuralProperties; + nonUpdatableNavigationProperties = nonUpdatableNavigationProperties ?? EmptyNavigationProperties; + + IList properties = new List + { + new EdmPropertyConstructor(CapabilitiesVocabularyConstants.UpdateRestrictionsUpdatable, + new EdmBooleanConstant(isUpdatable)), + + new EdmPropertyConstructor(CapabilitiesVocabularyConstants.UpdateRestrictionsNonUpdatableProperties, + new EdmCollectionExpression( + nonUpdatableProperties.Select(p => new EdmPropertyPathExpression(p.Name)).ToArray())), + + new EdmPropertyConstructor(CapabilitiesVocabularyConstants.UpdateRestrictionsNonUpdatableNavigationProperties, + new EdmCollectionExpression( + nonUpdatableNavigationProperties.Select(p => new EdmNavigationPropertyPathExpression(p.Name)).ToArray())) + }; + + model.SetVocabularyAnnotation(target, properties, CapabilitiesVocabularyConstants.UpdateRestrictions); + } + + /// + /// Set Org.OData.Capabilities.V1.DeleteRestrictions to target. + /// + /// The model referenced to. + /// The target entity set to set the inline annotation. + /// This entity set can be deleted. + /// These navigation properties do not allow DeleteLink requests. + public static void SetDeleteRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target, bool isDeletable, + IEnumerable nonDeletableNavigationProperties) + { + if (model == null) + { + throw Error.ArgumentNull("model"); + } + + if (target == null) + { + throw Error.ArgumentNull("target"); + } + + nonDeletableNavigationProperties = nonDeletableNavigationProperties ?? EmptyNavigationProperties; + + IList properties = new List + { + new EdmPropertyConstructor(CapabilitiesVocabularyConstants.DeleteRestrictionsDeletable, + new EdmBooleanConstant(isDeletable)), + + new EdmPropertyConstructor(CapabilitiesVocabularyConstants.DeleteRestrictionsNonDeletableNavigationProperties, + new EdmCollectionExpression( + nonDeletableNavigationProperties.Select(p => new EdmNavigationPropertyPathExpression(p.Name)).ToArray())) + }; + + model.SetVocabularyAnnotation(target, properties, CapabilitiesVocabularyConstants.DeleteRestrictions); + } + private static void SetVocabularyAnnotation(this EdmModel model, IEdmVocabularyAnnotatable target, IList properties, string qualifiedName) { diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/EdmModelHelperMethods.cs b/src/Microsoft.AspNet.OData.Shared/Builder/EdmModelHelperMethods.cs index 0339a1c4d1..34affdd871 100644 --- a/src/Microsoft.AspNet.OData.Shared/Builder/EdmModelHelperMethods.cs +++ b/src/Microsoft.AspNet.OData.Shared/Builder/EdmModelHelperMethods.cs @@ -674,6 +674,106 @@ private static void AddCapabilitiesVocabularyAnnotations(this EdmModel model, IE model.AddFilterRestrictionsAnnotation(entitySet, entitySetConfig, edmTypeMap); model.AddSortRestrictionsAnnotation(entitySet, entitySetConfig, edmTypeMap); model.AddExpandRestrictionsAnnotation(entitySet, entitySetConfig, edmTypeMap); + model.AddInsertRestrictionsAnnotation(entitySet, entitySetConfig, edmTypeMap); + model.AddUpdateRestrictionsAnnotation(entitySet, entitySetConfig, edmTypeMap); + model.AddDeleteRestrictionsAnnotation(entitySet, entitySetConfig, edmTypeMap); + } + } + + private static void AddInsertRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target, + EntitySetConfiguration entitySetConfiguration, EdmTypeMap edmTypeMap) + { + EntityTypeConfiguration entityTypeConfig = entitySetConfiguration.EntityType; + + IEnumerable notInsertableProperties = entityTypeConfig.Properties.Where(property => property.NotInsertable); + + IList nonInsertableProperties = new List(); + IList nonInsertableNavigationProperties = new List(); + foreach (PropertyConfiguration property in notInsertableProperties) + { + IEdmProperty value; + if (edmTypeMap.EdmProperties.TryGetValue(property.PropertyInfo, out value)) + { + if (value != null) + { + if (value.PropertyKind == EdmPropertyKind.Navigation) + { + nonInsertableNavigationProperties.Add((IEdmNavigationProperty)value); + } + else + { + nonInsertableProperties.Add(value); + } + } + } + } + + if (entitySetConfiguration.NotInsertable || nonInsertableProperties.Any() || nonInsertableNavigationProperties.Any()) + { + model.SetInsertRestrictionsAnnotation(target, !entitySetConfiguration.NotInsertable, nonInsertableProperties, nonInsertableNavigationProperties); + } + } + + private static void AddUpdateRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target, + EntitySetConfiguration entitySetConfiguration, EdmTypeMap edmTypeMap) + { + EntityTypeConfiguration entityTypeConfig = entitySetConfiguration.EntityType; + + IEnumerable notUpdatableProperties = entityTypeConfig.Properties.Where(property => property.NotUpdatable); + + IList nonUpdatableProperties = new List(); + IList nonUpdatableNavigationProperties = new List(); + foreach (PropertyConfiguration property in notUpdatableProperties) + { + IEdmProperty value; + if (edmTypeMap.EdmProperties.TryGetValue(property.PropertyInfo, out value)) + { + if (value != null) + { + if (value.PropertyKind == EdmPropertyKind.Navigation) + { + nonUpdatableNavigationProperties.Add((IEdmNavigationProperty)value); + } + else + { + nonUpdatableProperties.Add(value); + } + } + } + } + + if (entitySetConfiguration.NotUpdatable || nonUpdatableProperties.Any() || nonUpdatableNavigationProperties.Any()) + { + model.SetUpdateRestrictionsAnnotation(target, !entitySetConfiguration.NotUpdatable, nonUpdatableProperties, nonUpdatableNavigationProperties); + } + } + + private static void AddDeleteRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target, + EntitySetConfiguration entitySetConfiguration, EdmTypeMap edmTypeMap) + { + EntityTypeConfiguration entityTypeConfig = entitySetConfiguration.EntityType; + + IEnumerable notDeletableProperties = entityTypeConfig.Properties.Where(property => property.NotDeletable); + + IList nonDeletableNavigationProperties = new List(); + foreach (PropertyConfiguration property in notDeletableProperties) + { + IEdmProperty value; + if (edmTypeMap.EdmProperties.TryGetValue(property.PropertyInfo, out value)) + { + if (value != null) + { + if (value.PropertyKind == EdmPropertyKind.Navigation) + { + nonDeletableNavigationProperties.Add((IEdmNavigationProperty)value); + } + } + } + } + + if (entitySetConfiguration.NotDeletable || nonDeletableNavigationProperties.Any()) + { + model.SetDeleteRestrictionsAnnotation(target, !entitySetConfiguration.NotDeletable, nonDeletableNavigationProperties); } } diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfiguration.cs index 0d03f916cd..ade61e6423 100644 --- a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfiguration.cs +++ b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfiguration.cs @@ -574,5 +574,74 @@ private static Type VerifyBindingSegment(Type current, MemberInfo info) return propertyInfo.PropertyType; } + + /// + /// Gets or sets whether the entity set is not insertable. Default is false. + /// + public bool NotInsertable { get; set; } + + /// + /// Gets or sets whether the entity set is not updatable. Default is false. + /// + public bool NotUpdatable { get; set; } + + /// + /// Gets or sets whether the entity set is not deletable. Default is false. + /// + public bool NotDeletable { get; set; } + + /// + /// Sets the entity set as not insertable. + /// + public virtual NavigationSourceConfiguration IsNotInsertable() + { + NotInsertable = true; + return this; + } + + /// + /// Sets the entity set as insertable. + /// + public virtual NavigationSourceConfiguration IsInsertable() + { + NotInsertable = false; + return this; + } + + /// + /// Sets the entity set as not updatable. + /// + public virtual NavigationSourceConfiguration IsNotUpdatable() + { + NotUpdatable = true; + return this; + } + + /// + /// Sets the entity set as updatable. + /// + public virtual NavigationSourceConfiguration IsUpdatable() + { + NotUpdatable = false; + return this; + } + + /// + /// Sets the entity set as not deletable. + /// + public virtual NavigationSourceConfiguration IsNotDeletable() + { + NotDeletable = true; + return this; + } + + /// + /// Sets the entity set as deletable. + /// + public virtual NavigationSourceConfiguration IsDeletable() + { + NotDeletable = false; + return this; + } } } diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfigurationOfTEntityType.cs b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfigurationOfTEntityType.cs index 98cc80bc09..ee32bb77a8 100644 --- a/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfigurationOfTEntityType.cs +++ b/src/Microsoft.AspNet.OData.Shared/Builder/NavigationSourceConfigurationOfTEntityType.cs @@ -774,5 +774,59 @@ private static ResourceContext UpCastEntityContext(ResourceContext StructuredType = context.StructuredType }; } + + /// + /// Sets the entity set as not insertable. + /// + public virtual NavigationSourceConfiguration IsNotInsertable() + { + _configuration.IsNotInsertable(); + return this; + } + + /// + /// Sets the entity set as insertable. + /// + public virtual NavigationSourceConfiguration IsInsertable() + { + _configuration.IsInsertable(); + return this; + } + + /// + /// Sets the entity set as not updatable. + /// + public virtual NavigationSourceConfiguration IsNotUpdatable() + { + _configuration.IsNotUpdatable(); + return this; + } + + /// + /// Sets the entity set as updatable. + /// + public virtual NavigationSourceConfiguration IsUpdatable() + { + _configuration.IsUpdatable(); + return this; + } + + /// + /// Sets the entity set as not deletable. + /// + public virtual NavigationSourceConfiguration IsNotDeletable() + { + _configuration.IsNotDeletable(); + return this; + } + + /// + /// Sets the entity set as deletable. + /// + public virtual NavigationSourceConfiguration IsDeletable() + { + _configuration.IsDeletable(); + return this; + } } } diff --git a/src/Microsoft.AspNet.OData.Shared/Builder/PropertyConfiguration.cs b/src/Microsoft.AspNet.OData.Shared/Builder/PropertyConfiguration.cs index 8891e030b1..5a7f71a278 100644 --- a/src/Microsoft.AspNet.OData.Shared/Builder/PropertyConfiguration.cs +++ b/src/Microsoft.AspNet.OData.Shared/Builder/PropertyConfiguration.cs @@ -147,6 +147,21 @@ public bool Unsortable /// public bool NotCountable { get; set; } + /// + /// Gets or sets whether the property is not insertable. Default is false. + /// + public bool NotInsertable { get; set; } + + /// + /// Gets or sets whether the property is not updatable. Default is false. + /// + public bool NotUpdatable { get; set; } + + /// + /// Gets or sets whether the property is not deletable. Default is false. + /// + public bool NotDeletable { get; set; } + /// /// Get or sets order in "order by" expression. /// @@ -265,6 +280,60 @@ public PropertyConfiguration IsCountable() return this; } + /// + /// Sets the property as not insertable. + /// + public PropertyConfiguration IsNotInsertable() + { + NotInsertable = true; + return this; + } + + /// + /// Sets the property as insertable. + /// + public PropertyConfiguration IsInsertable() + { + NotInsertable = false; + return this; + } + + /// + /// Sets the property as not updatable. + /// + public PropertyConfiguration IsNotUpdatable() + { + NotUpdatable = true; + return this; + } + + /// + /// Sets the property as updatable. + /// + public PropertyConfiguration IsUpdatable() + { + NotUpdatable = false; + return this; + } + + /// + /// Sets the property as not deletable. + /// + public PropertyConfiguration IsNotDeletable() + { + NotDeletable = true; + return this; + } + + /// + /// Sets the property as deletable. + /// + public PropertyConfiguration IsDeletable() + { + NotDeletable = false; + return this; + } + /// /// Sets this property is countable. /// From 7061ba7f810146fa410b21ee7b6f7776748a5b9d Mon Sep 17 00:00:00 2001 From: Brecht Debaere Date: Thu, 28 Feb 2019 03:42:07 +0100 Subject: [PATCH 2/3] Update bsl file. --- .../Microsoft.AspNet.OData.PublicApi.bsl | 24 +++++++++++++++++++ .../Microsoft.AspNetCore.OData.PublicApi.bsl | 24 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/test/UnitTest/Microsoft.AspNet.OData.Test/PublicApi/Microsoft.AspNet.OData.PublicApi.bsl b/test/UnitTest/Microsoft.AspNet.OData.Test/PublicApi/Microsoft.AspNet.OData.PublicApi.bsl index aee7874094..dd1d7422ea 100644 --- a/test/UnitTest/Microsoft.AspNet.OData.Test/PublicApi/Microsoft.AspNet.OData.PublicApi.bsl +++ b/test/UnitTest/Microsoft.AspNet.OData.Test/PublicApi/Microsoft.AspNet.OData.PublicApi.bsl @@ -929,6 +929,9 @@ public abstract class Microsoft.AspNet.OData.Builder.NavigationSourceConfigurati System.Type ClrType { public get; } EntityTypeConfiguration EntityType { public virtual get; } string Name { public get; } + bool NotDeletable { public get; public set; } + bool NotInsertable { public get; public set; } + bool NotUpdatable { public get; public set; } public virtual NavigationPropertyBindingConfiguration AddBinding (NavigationPropertyConfiguration navigationConfiguration, NavigationSourceConfiguration targetNavigationSource) public virtual NavigationPropertyBindingConfiguration AddBinding (NavigationPropertyConfiguration navigationConfiguration, NavigationSourceConfiguration targetNavigationSource, System.Collections.Generic.IList`1[[System.Reflection.MemberInfo]] bindingPath) @@ -946,6 +949,12 @@ public abstract class Microsoft.AspNet.OData.Builder.NavigationSourceConfigurati public virtual NavigationSourceConfiguration HasNavigationPropertyLink (NavigationPropertyConfiguration navigationProperty, NavigationLinkBuilder navigationLinkBuilder) public virtual NavigationSourceConfiguration HasReadLink (Microsoft.AspNet.OData.Builder.SelfLinkBuilder`1[[System.Uri]] readLinkBuilder) public virtual NavigationSourceConfiguration HasUrl (string url) + public virtual NavigationSourceConfiguration IsDeletable () + public virtual NavigationSourceConfiguration IsInsertable () + public virtual NavigationSourceConfiguration IsNotDeletable () + public virtual NavigationSourceConfiguration IsNotInsertable () + public virtual NavigationSourceConfiguration IsNotUpdatable () + public virtual NavigationSourceConfiguration IsUpdatable () public virtual void RemoveBinding (NavigationPropertyConfiguration navigationConfiguration) public virtual void RemoveBinding (NavigationPropertyConfiguration navigationConfiguration, string bindingPath) } @@ -978,6 +987,12 @@ public abstract class Microsoft.AspNet.OData.Builder.NavigationSourceConfigurati public NavigationPropertyBindingConfiguration HasSingletonBinding (Expression`1 navigationExpression, NavigationSourceConfiguration`1 targetSingleton) public NavigationPropertyBindingConfiguration HasSingletonBinding (Expression`1 navigationExpression, string singletonName) public NavigationPropertyBindingConfiguration HasSingletonBinding (Expression`1 navigationExpression, string singletonName) + public virtual NavigationSourceConfiguration`1 IsDeletable () + public virtual NavigationSourceConfiguration`1 IsInsertable () + public virtual NavigationSourceConfiguration`1 IsNotDeletable () + public virtual NavigationSourceConfiguration`1 IsNotInsertable () + public virtual NavigationSourceConfiguration`1 IsNotUpdatable () + public virtual NavigationSourceConfiguration`1 IsUpdatable () } public abstract class Microsoft.AspNet.OData.Builder.OperationConfiguration { @@ -1033,10 +1048,13 @@ public abstract class Microsoft.AspNet.OData.Builder.PropertyConfiguration { string Name { public get; public set; } bool NonFilterable { public get; public set; } bool NotCountable { public get; public set; } + bool NotDeletable { public get; public set; } bool NotExpandable { public get; public set; } bool NotFilterable { public get; public set; } + bool NotInsertable { public get; public set; } bool NotNavigable { public get; public set; } bool NotSortable { public get; public set; } + bool NotUpdatable { public get; public set; } int Order { public get; public set; } System.Reflection.PropertyInfo PropertyInfo { public get; } QueryConfiguration QueryConfiguration { public get; public set; } @@ -1058,17 +1076,23 @@ public abstract class Microsoft.AspNet.OData.Builder.PropertyConfiguration { public PropertyConfiguration Filter (string[] properties) public PropertyConfiguration Filter (QueryOptionSetting setting, string[] properties) public PropertyConfiguration IsCountable () + public PropertyConfiguration IsDeletable () public PropertyConfiguration IsExpandable () public PropertyConfiguration IsFilterable () + public PropertyConfiguration IsInsertable () public PropertyConfiguration IsNavigable () public PropertyConfiguration IsNonFilterable () public PropertyConfiguration IsNotCountable () + public PropertyConfiguration IsNotDeletable () public PropertyConfiguration IsNotExpandable () public PropertyConfiguration IsNotFilterable () + public PropertyConfiguration IsNotInsertable () public PropertyConfiguration IsNotNavigable () public PropertyConfiguration IsNotSortable () + public PropertyConfiguration IsNotUpdatable () public PropertyConfiguration IsSortable () public PropertyConfiguration IsUnsortable () + public PropertyConfiguration IsUpdatable () public PropertyConfiguration OrderBy () public PropertyConfiguration OrderBy (QueryOptionSetting setting) public PropertyConfiguration OrderBy (string[] properties) diff --git a/test/UnitTest/Microsoft.AspNetCore.OData.Test/PublicApi/Microsoft.AspNetCore.OData.PublicApi.bsl b/test/UnitTest/Microsoft.AspNetCore.OData.Test/PublicApi/Microsoft.AspNetCore.OData.PublicApi.bsl index 315bd21905..ccbd1b25fe 100644 --- a/test/UnitTest/Microsoft.AspNetCore.OData.Test/PublicApi/Microsoft.AspNetCore.OData.PublicApi.bsl +++ b/test/UnitTest/Microsoft.AspNetCore.OData.Test/PublicApi/Microsoft.AspNetCore.OData.PublicApi.bsl @@ -977,6 +977,9 @@ public abstract class Microsoft.AspNet.OData.Builder.NavigationSourceConfigurati System.Type ClrType { public get; } EntityTypeConfiguration EntityType { public virtual get; } string Name { public get; } + bool NotDeletable { public get; public set; } + bool NotInsertable { public get; public set; } + bool NotUpdatable { public get; public set; } public virtual NavigationPropertyBindingConfiguration AddBinding (NavigationPropertyConfiguration navigationConfiguration, NavigationSourceConfiguration targetNavigationSource) public virtual NavigationPropertyBindingConfiguration AddBinding (NavigationPropertyConfiguration navigationConfiguration, NavigationSourceConfiguration targetNavigationSource, System.Collections.Generic.IList`1[[System.Reflection.MemberInfo]] bindingPath) @@ -994,6 +997,12 @@ public abstract class Microsoft.AspNet.OData.Builder.NavigationSourceConfigurati public virtual NavigationSourceConfiguration HasNavigationPropertyLink (NavigationPropertyConfiguration navigationProperty, NavigationLinkBuilder navigationLinkBuilder) public virtual NavigationSourceConfiguration HasReadLink (Microsoft.AspNet.OData.Builder.SelfLinkBuilder`1[[System.Uri]] readLinkBuilder) public virtual NavigationSourceConfiguration HasUrl (string url) + public virtual NavigationSourceConfiguration IsDeletable () + public virtual NavigationSourceConfiguration IsInsertable () + public virtual NavigationSourceConfiguration IsNotDeletable () + public virtual NavigationSourceConfiguration IsNotInsertable () + public virtual NavigationSourceConfiguration IsNotUpdatable () + public virtual NavigationSourceConfiguration IsUpdatable () public virtual void RemoveBinding (NavigationPropertyConfiguration navigationConfiguration) public virtual void RemoveBinding (NavigationPropertyConfiguration navigationConfiguration, string bindingPath) } @@ -1026,6 +1035,12 @@ public abstract class Microsoft.AspNet.OData.Builder.NavigationSourceConfigurati public NavigationPropertyBindingConfiguration HasSingletonBinding (Expression`1 navigationExpression, NavigationSourceConfiguration`1 targetSingleton) public NavigationPropertyBindingConfiguration HasSingletonBinding (Expression`1 navigationExpression, string singletonName) public NavigationPropertyBindingConfiguration HasSingletonBinding (Expression`1 navigationExpression, string singletonName) + public virtual NavigationSourceConfiguration`1 IsDeletable () + public virtual NavigationSourceConfiguration`1 IsInsertable () + public virtual NavigationSourceConfiguration`1 IsNotDeletable () + public virtual NavigationSourceConfiguration`1 IsNotInsertable () + public virtual NavigationSourceConfiguration`1 IsNotUpdatable () + public virtual NavigationSourceConfiguration`1 IsUpdatable () } public abstract class Microsoft.AspNet.OData.Builder.OperationConfiguration { @@ -1081,10 +1096,13 @@ public abstract class Microsoft.AspNet.OData.Builder.PropertyConfiguration { string Name { public get; public set; } bool NonFilterable { public get; public set; } bool NotCountable { public get; public set; } + bool NotDeletable { public get; public set; } bool NotExpandable { public get; public set; } bool NotFilterable { public get; public set; } + bool NotInsertable { public get; public set; } bool NotNavigable { public get; public set; } bool NotSortable { public get; public set; } + bool NotUpdatable { public get; public set; } int Order { public get; public set; } System.Reflection.PropertyInfo PropertyInfo { public get; } QueryConfiguration QueryConfiguration { public get; public set; } @@ -1106,17 +1124,23 @@ public abstract class Microsoft.AspNet.OData.Builder.PropertyConfiguration { public PropertyConfiguration Filter (string[] properties) public PropertyConfiguration Filter (QueryOptionSetting setting, string[] properties) public PropertyConfiguration IsCountable () + public PropertyConfiguration IsDeletable () public PropertyConfiguration IsExpandable () public PropertyConfiguration IsFilterable () + public PropertyConfiguration IsInsertable () public PropertyConfiguration IsNavigable () public PropertyConfiguration IsNonFilterable () public PropertyConfiguration IsNotCountable () + public PropertyConfiguration IsNotDeletable () public PropertyConfiguration IsNotExpandable () public PropertyConfiguration IsNotFilterable () + public PropertyConfiguration IsNotInsertable () public PropertyConfiguration IsNotNavigable () public PropertyConfiguration IsNotSortable () + public PropertyConfiguration IsNotUpdatable () public PropertyConfiguration IsSortable () public PropertyConfiguration IsUnsortable () + public PropertyConfiguration IsUpdatable () public PropertyConfiguration OrderBy () public PropertyConfiguration OrderBy (QueryOptionSetting setting) public PropertyConfiguration OrderBy (string[] properties) From 14140b9bd4ce13ada8b80334bd47e34c521f5c48 Mon Sep 17 00:00:00 2001 From: Brecht Debaere Date: Thu, 28 Feb 2019 03:42:21 +0100 Subject: [PATCH 3/3] Add Insertable, Updatable, Deletable to dictionary. --- src/CodeAnalysisDictionary.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CodeAnalysisDictionary.xml b/src/CodeAnalysisDictionary.xml index fdd4e0ea74..f59ec831ea 100644 --- a/src/CodeAnalysisDictionary.xml +++ b/src/CodeAnalysisDictionary.xml @@ -55,6 +55,9 @@ ModelName BSON Untyped + Insertable + Updatable + Deletable WebPage