嗨,我有分层对象结构,例如
public class Department
{
public Guid ID {get; set;}
public string Name{get; set;}
}
public class Employee
{
public Guid ID {get; set;}
public string Name{get; set;}
public Department Department {get;set;}
}
我创建了一个 formatedoutput.ps1xml 文件来在 powershell 中显示员工对象
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<View>
<Name>EmpView</Name>
<ViewSelectedBy>
<TypeName>Employee</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Width>16</Width>
</TableColumnHeader>
<TableColumnHeader>
<Width>16</Width>
</TableColumnHeader>
<TableColumnHeader/>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>ID</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Department.Name</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
我已经在 PS 中使用以下 cmdlet 注册了我的 xml 文件
update-formatdata -prependpath c:\formatedoutput.ps1xml
它显示表格输出,显示员工 ID 和姓名,但不显示部门名称。
我认为是因为它在嵌套对象中
谁能帮我显示部门名称