我正在使用具有实体框架的强类型中继器,并且可以使用外键访问每个属性,但是每个属性都是基于多对多关系的
<asp:Repeater ID="rptOperadores" runat="server" ItemType="InventarioCiclico.xOperador" SelectMethod="rptOperadores_GetData">
<HeaderTemplate>
<table id="tblOperadores" class="table table-sm table-bordered table-hover bg-white table-striped text-center">
<thead class="thead-dark">
<tr>
<th style="text-align: center;">Nome</th>
<th style="text-align: center;">Armazém</th>
<th style="text-align: center; width: 50px;">Status</th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="lblNome" runat="server" Text='<%# Item.xColaborador.Nome %>' />
</td>
<td>
<asp:Label ID="lblArmazem" runat="server" Text='<%# Item.xArmazem.SelectMany(c => c.Armazem) %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblStatus" runat="server" Text='<%# Item.xColaborador.xUtilizador.Activo %>'></asp:Label>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
这是我的模特。它们都具有导航属性,但是xOperator无法直接访问xArmazem属性,但是其他所有属性都可以?
public IEnumerable<InventarioCiclico.xOperador> rptOperadores_GetData()
{
InventarioCiclicoContext db = new InventarioCiclicoContext();
var result = from c in db.xOperador select c;
return result;
}