abp
/
MyProjectNameModuleExtensionConfigurator.cs
68 строк · 2.3 Кб
1using Volo.Abp.Threading;2
3namespace MyCompanyName.MyProjectName;4
5public static class MyProjectNameModuleExtensionConfigurator6{
7private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();8
9public static void Configure()10{11OneTimeRunner.Run(() =>12{13ConfigureExistingProperties();14ConfigureExtraProperties();15});16}17
18private static void ConfigureExistingProperties()19{20/* You can change max lengths for properties of the21* entities defined in the modules used by your application.
22*
23* Example: Change user and role name max lengths
24
25AbpUserConsts.MaxNameLength = 99;
26IdentityRoleConsts.MaxNameLength = 99;
27
28* Notice: It is not suggested to change property lengths
29* unless you really need it. Go with the standard values wherever possible.
30*
31* If you are using EF Core, you will need to run the add-migration command after your changes.
32*/
33}34
35private static void ConfigureExtraProperties()36{37/* You can configure extra properties for the38* entities defined in the modules used by your application.
39*
40* This class can be used to define these extra properties
41* with a high level, easy to use API.
42*
43* Example: Add a new property to the user entity of the identity module
44
45ObjectExtensionManager.Instance.Modules()
46.ConfigureIdentity(identity =>
47{
48identity.ConfigureUser(user =>
49{
50user.AddOrUpdateProperty<string>( //property type: string
51"SocialSecurityNumber", //property name
52property =>
53{
54//validation rules
55property.Attributes.Add(new RequiredAttribute());
56property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4});
57
58//...other configurations for this property
59}
60);
61});
62});
63
64* See the documentation for more:
65* https://docs.abp.io/en/abp/latest/Module-Entity-Extensions
66*/
67}68}
69