diff --git a/Changelog.md b/Changelog.md index cae3d347..9beed361 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +# EF Core 4.1.0 + +* Generate `[Required(AllowEmptyStrings=true)]` instead of `[Required]` on client for non nullable string properties + # 5.8.0 This release gives some ❤️ to AvaloniaUI and other frameworks which use IList for data binding. diff --git a/src/OpenRiaServices.Client/Framework/InvokeResult.cs b/src/OpenRiaServices.Client/Framework/InvokeResult.cs index c17cd8a4..0c4c9123 100644 --- a/src/OpenRiaServices.Client/Framework/InvokeResult.cs +++ b/src/OpenRiaServices.Client/Framework/InvokeResult.cs @@ -11,6 +11,9 @@ namespace OpenRiaServices.Client /// interface IInvokeResult { + /// + /// Get the value returned by the Invoke operation, if any. If the Invoke operation does not return a value, this will be null. + /// object? Value { get; } } @@ -27,15 +30,13 @@ public class InvokeResult : IInvokeResult /// public class InvokeResult : InvokeResult, IInvokeResult { - private readonly T _value; - /// /// Initializes a new instance of the class. /// /// The value. public InvokeResult(T value) { - _value = value; + Value = value; } /// @@ -44,16 +45,16 @@ public InvokeResult(T value) /// /// The value. /// - public T? Value => _value; + public T Value { get; } - object? IInvokeResult.Value => _value; + object? IInvokeResult.Value => Value; /// /// Implicit conversion to so that does not need to be used /// in most cases. /// /// - public static implicit operator T?(InvokeResult invokeResult) + public static implicit operator T(InvokeResult invokeResult) { return invokeResult.Value; } diff --git a/src/OpenRiaServices.Server.EntityFrameworkCore/Framework/EFCoreTypeDescriptor.cs b/src/OpenRiaServices.Server.EntityFrameworkCore/Framework/EFCoreTypeDescriptor.cs index d8a27a07..5346a754 100644 --- a/src/OpenRiaServices.Server.EntityFrameworkCore/Framework/EFCoreTypeDescriptor.cs +++ b/src/OpenRiaServices.Server.EntityFrameworkCore/Framework/EFCoreTypeDescriptor.cs @@ -184,7 +184,7 @@ protected override IEnumerable GetMemberAttributes(PropertyDescriptor && !databaseGenerated && pd.Attributes[typeof(RequiredAttribute)] == null) { - attributes.Add(new RequiredAttribute()); + attributes.Add(new RequiredAttribute() { AllowEmptyStrings = (property.ClrType == typeof(string)) }); } bool isStringType = pd.PropertyType == typeof(string) || pd.PropertyType == typeof(char[]); diff --git a/src/OpenRiaServices.Server.EntityFrameworkCore/Framework/OpenRiaServices.Server.EntityFrameworkCore.csproj b/src/OpenRiaServices.Server.EntityFrameworkCore/Framework/OpenRiaServices.Server.EntityFrameworkCore.csproj index 847792f9..35c8f34a 100644 --- a/src/OpenRiaServices.Server.EntityFrameworkCore/Framework/OpenRiaServices.Server.EntityFrameworkCore.csproj +++ b/src/OpenRiaServices.Server.EntityFrameworkCore/Framework/OpenRiaServices.Server.EntityFrameworkCore.csproj @@ -3,8 +3,8 @@ net472;net8.0;net10.0 $(DefineConstants);SERVERFX;EFCORE true - 4.0.0 - 4.0.0 + 4.1.0 + 4.1.0 true README.md diff --git a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/EF/Northwind_EFCore.g.cs b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/EF/Northwind_EFCore.g.cs index 59227f61..110c7d45 100644 --- a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/EF/Northwind_EFCore.g.cs +++ b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/EF/Northwind_EFCore.g.cs @@ -97,7 +97,7 @@ public int CategoryID /// Gets or sets the 'CategoryName' value. /// [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] [StringLength(15)] public string CategoryName { @@ -339,7 +339,7 @@ public string City /// [ConcurrencyCheck()] [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] [RoundtripOriginal()] [StringLength(40)] public string CompanyName @@ -450,7 +450,7 @@ public string Country [DataMember()] [Editable(false, AllowInitialValue=true)] [Key()] - [Required()] + [Required(AllowEmptyStrings=true)] [RoundtripOriginal()] [StringLength(15)] public string CustomerID @@ -1736,7 +1736,7 @@ public int ProductID /// [ConcurrencyCheck()] [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] [RoundtripOriginal()] [StringLength(40)] public string ProductName @@ -2219,7 +2219,7 @@ public Region() /// Gets or sets the 'RegionDescription' value. /// [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] [StringLength(50)] public string RegionDescription { @@ -2421,7 +2421,7 @@ public int RegionID /// Gets or sets the 'TerritoryDescription' value. /// [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] [StringLength(50)] public string TerritoryDescription { @@ -2449,7 +2449,7 @@ public string TerritoryDescription [DataMember()] [Editable(false, AllowInitialValue=true)] [Key()] - [Required()] + [Required(AllowEmptyStrings=true)] [RoundtripOriginal()] [StringLength(20)] public string TerritoryID diff --git a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/EF/Northwind_EFCore.g.vb b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/EF/Northwind_EFCore.g.vb index 2bed9b8e..1c4ae4b6 100644 --- a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/EF/Northwind_EFCore.g.vb +++ b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/EF/Northwind_EFCore.g.vb @@ -108,7 +108,7 @@ Namespace EFCoreModels.Northwind ''' Gets or sets the 'CategoryName' value. ''' _ Public Property CategoryName() As String Get @@ -346,7 +346,7 @@ Namespace EFCoreModels.Northwind ''' _ Public Property CompanyName() As String @@ -441,7 +441,7 @@ Namespace EFCoreModels.Northwind DataMember(), _ Editable(false, AllowInitialValue:=true), _ Key(), _ - Required(), _ + Required(AllowEmptyStrings:=true), _ RoundtripOriginal(), _ StringLength(15)> _ Public Property CustomerID() As String @@ -1629,7 +1629,7 @@ Namespace EFCoreModels.Northwind ''' _ Public Property ProductName() As String @@ -2064,7 +2064,7 @@ Namespace EFCoreModels.Northwind ''' Gets or sets the 'RegionDescription' value. ''' _ Public Property RegionDescription() As String Get @@ -2246,7 +2246,7 @@ Namespace EFCoreModels.Northwind ''' Gets or sets the 'TerritoryDescription' value. ''' _ Public Property TerritoryDescription() As String Get @@ -2270,7 +2270,7 @@ Namespace EFCoreModels.Northwind _ Public Property TerritoryID() As String diff --git a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCoreContextScenarios.g.cs b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCoreContextScenarios.g.cs index 59227f61..110c7d45 100644 --- a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCoreContextScenarios.g.cs +++ b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCoreContextScenarios.g.cs @@ -97,7 +97,7 @@ public int CategoryID /// Gets or sets the 'CategoryName' value. /// [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] [StringLength(15)] public string CategoryName { @@ -339,7 +339,7 @@ public string City /// [ConcurrencyCheck()] [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] [RoundtripOriginal()] [StringLength(40)] public string CompanyName @@ -450,7 +450,7 @@ public string Country [DataMember()] [Editable(false, AllowInitialValue=true)] [Key()] - [Required()] + [Required(AllowEmptyStrings=true)] [RoundtripOriginal()] [StringLength(15)] public string CustomerID @@ -1736,7 +1736,7 @@ public int ProductID /// [ConcurrencyCheck()] [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] [RoundtripOriginal()] [StringLength(40)] public string ProductName @@ -2219,7 +2219,7 @@ public Region() /// Gets or sets the 'RegionDescription' value. /// [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] [StringLength(50)] public string RegionDescription { @@ -2421,7 +2421,7 @@ public int RegionID /// Gets or sets the 'TerritoryDescription' value. /// [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] [StringLength(50)] public string TerritoryDescription { @@ -2449,7 +2449,7 @@ public string TerritoryDescription [DataMember()] [Editable(false, AllowInitialValue=true)] [Key()] - [Required()] + [Required(AllowEmptyStrings=true)] [RoundtripOriginal()] [StringLength(20)] public string TerritoryID diff --git a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCoreContextScenarios.g.vb b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCoreContextScenarios.g.vb index 2bed9b8e..1c4ae4b6 100644 --- a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCoreContextScenarios.g.vb +++ b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCoreContextScenarios.g.vb @@ -108,7 +108,7 @@ Namespace EFCoreModels.Northwind ''' Gets or sets the 'CategoryName' value. ''' _ Public Property CategoryName() As String Get @@ -346,7 +346,7 @@ Namespace EFCoreModels.Northwind ''' _ Public Property CompanyName() As String @@ -441,7 +441,7 @@ Namespace EFCoreModels.Northwind DataMember(), _ Editable(false, AllowInitialValue:=true), _ Key(), _ - Required(), _ + Required(AllowEmptyStrings:=true), _ RoundtripOriginal(), _ StringLength(15)> _ Public Property CustomerID() As String @@ -1629,7 +1629,7 @@ Namespace EFCoreModels.Northwind ''' _ Public Property ProductName() As String @@ -2064,7 +2064,7 @@ Namespace EFCoreModels.Northwind ''' Gets or sets the 'RegionDescription' value. ''' _ Public Property RegionDescription() As String Get @@ -2246,7 +2246,7 @@ Namespace EFCoreModels.Northwind ''' Gets or sets the 'TerritoryDescription' value. ''' _ Public Property TerritoryDescription() As String Get @@ -2270,7 +2270,7 @@ Namespace EFCoreModels.Northwind _ Public Property TerritoryID() As String diff --git a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCore_ComplexObject.g.cs b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCore_ComplexObject.g.cs index ee74ae88..ffdf155a 100644 --- a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCore_ComplexObject.g.cs +++ b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCore_ComplexObject.g.cs @@ -59,7 +59,7 @@ public Address() /// Gets or sets the 'AddressLine' value. /// [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] [StringLength(100)] public string AddressLine { @@ -85,7 +85,7 @@ public string AddressLine /// Gets or sets the 'City' value. /// [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] [StringLength(50)] public string City { @@ -171,7 +171,7 @@ public Address Address /// Gets or sets the 'HomePhone' value. /// [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] [StringLength(24)] public string HomePhone { @@ -421,7 +421,7 @@ public OwnedEntityWithBackNavigation() /// Gets or sets the 'Description' value. /// [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] public string Description { get @@ -481,7 +481,7 @@ public OwnedEntityWithExplicitId() /// Gets or sets the 'Description' value. /// [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] public string Description { get @@ -578,7 +578,7 @@ public OwnedEntityWithExplicitIdAndBackNavigation() /// Gets or sets the 'Description' value. /// [DataMember()] - [Required()] + [Required(AllowEmptyStrings=true)] public string Description { get diff --git a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCore_ComplexObject.g.vb b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCore_ComplexObject.g.vb index 39add133..5a777e74 100644 --- a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCore_ComplexObject.g.vb +++ b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/Default/Scenarios/EFCore_ComplexObject.g.vb @@ -69,7 +69,7 @@ Namespace EFCoreModels.Scenarios.OwnedTypes ''' Gets or sets the 'AddressLine' value. ''' _ Public Property AddressLine() As String Get @@ -91,7 +91,7 @@ Namespace EFCoreModels.Scenarios.OwnedTypes ''' Gets or sets the 'City' value. ''' _ Public Property City() As String Get @@ -174,7 +174,7 @@ Namespace EFCoreModels.Scenarios.OwnedTypes ''' Gets or sets the 'HomePhone' value. ''' _ Public Property HomePhone() As String Get @@ -406,7 +406,7 @@ Namespace EFCoreModels.Scenarios.OwnedTypes ''' Gets or sets the 'Description' value. ''' _ + Required(AllowEmptyStrings:=true)> _ Public Property Description() As String Get Return Me._description @@ -467,7 +467,7 @@ Namespace EFCoreModels.Scenarios.OwnedTypes ''' Gets or sets the 'Description' value. ''' _ + Required(AllowEmptyStrings:=true)> _ Public Property Description() As String Get Return Me._description @@ -561,7 +561,7 @@ Namespace EFCoreModels.Scenarios.OwnedTypes ''' Gets or sets the 'Description' value. ''' _ + Required(AllowEmptyStrings:=true)> _ Public Property Description() As String Get Return Me._description diff --git a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/FullTypeNames/Scenarios/EFCoreDbContextScenarios.g.cs b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/FullTypeNames/Scenarios/EFCoreDbContextScenarios.g.cs index e35f358d..54f94c43 100644 --- a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/FullTypeNames/Scenarios/EFCoreDbContextScenarios.g.cs +++ b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/FullTypeNames/Scenarios/EFCoreDbContextScenarios.g.cs @@ -86,7 +86,7 @@ public int CategoryID /// /// Gets or sets the 'CategoryName' value. /// - [global::System.ComponentModel.DataAnnotations.RequiredAttribute()] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(AllowEmptyStrings=true)] [global::System.ComponentModel.DataAnnotations.StringLengthAttribute(15)] [global::System.Runtime.Serialization.DataMemberAttribute()] public string CategoryName @@ -328,7 +328,7 @@ public string City /// Gets or sets the 'CompanyName' value. /// [global::System.ComponentModel.DataAnnotations.ConcurrencyCheckAttribute()] - [global::System.ComponentModel.DataAnnotations.RequiredAttribute()] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(AllowEmptyStrings=true)] [global::System.ComponentModel.DataAnnotations.RoundtripOriginalAttribute()] [global::System.ComponentModel.DataAnnotations.StringLengthAttribute(40)] [global::System.Runtime.Serialization.DataMemberAttribute()] @@ -439,7 +439,7 @@ public string Country [global::System.ComponentModel.DataAnnotations.ConcurrencyCheckAttribute()] [global::System.ComponentModel.DataAnnotations.EditableAttribute(false, AllowInitialValue=true)] [global::System.ComponentModel.DataAnnotations.KeyAttribute()] - [global::System.ComponentModel.DataAnnotations.RequiredAttribute()] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(AllowEmptyStrings=true)] [global::System.ComponentModel.DataAnnotations.RoundtripOriginalAttribute()] [global::System.ComponentModel.DataAnnotations.StringLengthAttribute(15)] [global::System.Runtime.Serialization.DataMemberAttribute()] @@ -1725,7 +1725,7 @@ public int ProductID /// Gets or sets the 'ProductName' value. /// [global::System.ComponentModel.DataAnnotations.ConcurrencyCheckAttribute()] - [global::System.ComponentModel.DataAnnotations.RequiredAttribute()] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(AllowEmptyStrings=true)] [global::System.ComponentModel.DataAnnotations.RoundtripOriginalAttribute()] [global::System.ComponentModel.DataAnnotations.StringLengthAttribute(40)] [global::System.Runtime.Serialization.DataMemberAttribute()] @@ -2208,7 +2208,7 @@ public Region() /// /// Gets or sets the 'RegionDescription' value. /// - [global::System.ComponentModel.DataAnnotations.RequiredAttribute()] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(AllowEmptyStrings=true)] [global::System.ComponentModel.DataAnnotations.StringLengthAttribute(50)] [global::System.Runtime.Serialization.DataMemberAttribute()] public string RegionDescription @@ -2410,7 +2410,7 @@ public int RegionID /// /// Gets or sets the 'TerritoryDescription' value. /// - [global::System.ComponentModel.DataAnnotations.RequiredAttribute()] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(AllowEmptyStrings=true)] [global::System.ComponentModel.DataAnnotations.StringLengthAttribute(50)] [global::System.Runtime.Serialization.DataMemberAttribute()] public string TerritoryDescription @@ -2438,7 +2438,7 @@ public string TerritoryDescription /// [global::System.ComponentModel.DataAnnotations.EditableAttribute(false, AllowInitialValue=true)] [global::System.ComponentModel.DataAnnotations.KeyAttribute()] - [global::System.ComponentModel.DataAnnotations.RequiredAttribute()] + [global::System.ComponentModel.DataAnnotations.RequiredAttribute(AllowEmptyStrings=true)] [global::System.ComponentModel.DataAnnotations.RoundtripOriginalAttribute()] [global::System.ComponentModel.DataAnnotations.StringLengthAttribute(20)] [global::System.Runtime.Serialization.DataMemberAttribute()] diff --git a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/FullTypeNames/Scenarios/EFCoreDbContextScenarios.g.vb b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/FullTypeNames/Scenarios/EFCoreDbContextScenarios.g.vb index 18566599..14651b63 100644 --- a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/FullTypeNames/Scenarios/EFCoreDbContextScenarios.g.vb +++ b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Baselines/FullTypeNames/Scenarios/EFCoreDbContextScenarios.g.vb @@ -96,7 +96,7 @@ Namespace EFCoreModels.Northwind ''' ''' Gets or sets the 'CategoryName' value. ''' - _ Public Property CategoryName() As String @@ -334,7 +334,7 @@ Namespace EFCoreModels.Northwind ''' Gets or sets the 'CompanyName' value. ''' _ @@ -429,7 +429,7 @@ Namespace EFCoreModels.Northwind _ @@ -1617,7 +1617,7 @@ Namespace EFCoreModels.Northwind ''' Gets or sets the 'ProductName' value. ''' _ @@ -2052,7 +2052,7 @@ Namespace EFCoreModels.Northwind ''' ''' Gets or sets the 'RegionDescription' value. ''' - _ Public Property RegionDescription() As String @@ -2234,7 +2234,7 @@ Namespace EFCoreModels.Northwind ''' ''' Gets or sets the 'TerritoryDescription' value. ''' - _ Public Property TerritoryDescription() As String @@ -2258,7 +2258,7 @@ Namespace EFCoreModels.Northwind ''' _