select new PermissionItem
{
Url = item.Module?.LinkUrl,
Role = item.Role?.Name,
}).ToList();
类似三元一次表达式?
item.Role?.Name
===>
if(item.Role==null)
return default(Name字段类型)
else
return item.Role.Name
刚刚自己试了下,差不多是你这样
@Cgrain:
https://www.cnblogs.com/linianhui/p/csharp6_null-conditional-operators.html#auto_id_1