Base solution for your next web application
Open Closed

Get DiplayName of Permission #3045


User avatar
0
ivanosw1 created

Hi, I don't figure out why I can get the displayname if I use AutoMap, but not if I do the same thing manually. Where is the magic ?

public class MyPermissionDto { public string DisplayName { get; set; }

}  

.....

var permissions = PermissionManager.GetAllPermissions(); var resultz = new List<MyPermissionDto>(); foreach (var rootPermission in permissions) { var flatPermission = rootPermission.MapTo<MyPermissionDto>(); resultz.Add(flatPermission); string thisWorks = flatPermission.DisplayName; string thisNotWorks = rootPermission.DisplayName }


3 Answer(s)
  • User Avatar
    0
    alirizaadiyahsi created

    Hi,

    Actually, "DisplayName" type is not string, it's type is "LocalizableString".

    "MapTo<T>" method converts it to localized string (LocalizableString to String), automatically. So magic is in Abp framework :)

    Check this: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/6076a126f975ea1721348f24c89ed7b44e9f2d6e/src/Abp.AutoMapper/AutoMapper/AbpAutoMapperModule.cs#L95">https://github.com/aspnetboilerplate/as ... ule.cs#L95</a>

  • User Avatar
    0
    ivanosw1 created

    Ok, great. Thank you alirizaadiyahsi.

  • User Avatar
    0
    alirizaadiyahsi created

    glad it helped...