mirror of https://github.com/abpframework/abp.git
7 changed files with 31 additions and 0 deletions
@ -0,0 +1,31 @@ |
|||
# How to add the user entity as a navigation property? |
|||
|
|||
In this post, I'll show you how to add the user as a navigation property in your new entity. |
|||
|
|||
To do this, open the ABP Suite. Create a new entity called `Note`. |
|||
|
|||
 |
|||
|
|||
Then add a string property called `Title`. |
|||
|
|||
 |
|||
|
|||
To be able to add a user navigation, we need to create a user DTO to map from entity. To do this, create a new folder called "Users" in `*.Application.Contracts` then add a new class called `AppUserDto` inherited from `IdentityUserDto`. |
|||
|
|||
 |
|||
|
|||
Create the mapping for `AppUserDto`. To do this, open `YourProjectApplicationAutoMapperProfile.cs` and add the below line: |
|||
|
|||
```csharp |
|||
CreateMap<AppUser, AppUserDto>().Ignore(x => x.ExtraProperties); |
|||
``` |
|||
|
|||
 |
|||
|
|||
Get back to ABP Suite, go to **Navigation Properties** tab. Click **Add Navigation Property** button. Browse `AppUser.cs` in `*.Domain\Users` folder. Then choose the `Name` item as display property. Browse `AppUserDto.cs` in `*.Contracts\Users` folder. Choose `Users` from Collection Names dropdown. |
|||
|
|||
 |
|||
|
|||
That's it! Click **Save and generate** button to create your page. You'll see the following page if there's everything goes well. |
|||
|
|||
 |
|||
|
After Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 223 KiB |
|
After Width: | Height: | Size: 180 KiB |
|
After Width: | Height: | Size: 302 KiB |
|
After Width: | Height: | Size: 153 KiB |
|
After Width: | Height: | Size: 92 KiB |
Loading…
Reference in new issue