Browse Source
Merge pull request #8612 from abpframework/extension-property-dbfix-tests
Use Enum.Parse to convert the enum.
pull/8617/head
İlkay İlknur
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
20 additions and
1 deletions
-
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs
-
framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Domain/ExtraProperties_Tests.cs
-
framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/Domain/TestEntityExtensionConfigurator.cs
|
|
|
@ -351,7 +351,7 @@ namespace Volo.Abp.EntityFrameworkCore |
|
|
|
} |
|
|
|
else if (conversionType.IsEnum) |
|
|
|
{ |
|
|
|
entryProperty.CurrentValue = Enum.ToObject(conversionType, entityProperty); |
|
|
|
entryProperty.CurrentValue = Enum.Parse(conversionType, entityProperty.ToString(), ignoreCase: true); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
|
@ -31,6 +31,9 @@ namespace Volo.Abp.EntityFrameworkCore.Domain |
|
|
|
london.ExtraProperties["ZipCode"] = null; |
|
|
|
london.ExtraProperties["Established"] = DateTime.MinValue; |
|
|
|
london.ExtraProperties["Guid"] = "a7ae2efe-d8d6-466b-92e3-da14aa6e1c5b"; |
|
|
|
london.ExtraProperties["EnumNumber"] = 2L; |
|
|
|
london.ExtraProperties["EnumNumberString"] = "2"; |
|
|
|
london.ExtraProperties["EnumLiteral"] = "White"; |
|
|
|
await CityRepository.UpdateAsync(london); |
|
|
|
|
|
|
|
var london2 = await CityRepository.FindByNameAsync("London"); |
|
|
|
@ -39,6 +42,9 @@ namespace Volo.Abp.EntityFrameworkCore.Domain |
|
|
|
london2.GetProperty<string>("ZipCode").ShouldBe(null); |
|
|
|
london2.GetProperty<DateTime?>("Established").ShouldBe(DateTime.MinValue); |
|
|
|
london2.GetProperty<Guid>("Guid").ShouldBe(new Guid("a7ae2efe-d8d6-466b-92e3-da14aa6e1c5b")); |
|
|
|
london2.GetProperty<Color>("EnumNumber").ShouldBe(Color.White); |
|
|
|
london2.GetProperty<Color>("EnumNumberString").ShouldBe(Color.White); |
|
|
|
london2.GetProperty<Color>("EnumLiteral").ShouldBe(Color.White); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
@ -52,5 +58,12 @@ namespace Volo.Abp.EntityFrameworkCore.Domain |
|
|
|
indexes.ShouldContain(x => x.IsUnique); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public enum Color |
|
|
|
{ |
|
|
|
Red = 0, |
|
|
|
Blue = 1, |
|
|
|
White = 2 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -29,6 +29,12 @@ namespace Volo.Abp.EntityFrameworkCore.Domain |
|
|
|
"Established" |
|
|
|
).MapEfCoreProperty<City, Guid>( |
|
|
|
"Guid" |
|
|
|
).MapEfCoreProperty<City, ExtraProperties_Tests.Color?>( |
|
|
|
"EnumNumber" |
|
|
|
).MapEfCoreProperty<City, ExtraProperties_Tests.Color>( |
|
|
|
"EnumNumberString" |
|
|
|
).MapEfCoreProperty<City, ExtraProperties_Tests.Color>( |
|
|
|
"EnumLiteral" |
|
|
|
); |
|
|
|
}); |
|
|
|
} |
|
|
|
|