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)
-
0
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>
-
0
Ok, great. Thank you alirizaadiyahsi.
-
0
glad it helped...