我有以下XAML代码:

    <sdk:DataGrid AutoGenerateColumns="False" Height="200" HorizontalAlignment="Left" ItemsSource="{Binding ElementName=ticketDomainDataSource, Path=Data}" Margin="8,43,0,0" Name="ticketDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Top" Width="795">
        <sdk:DataGrid.Columns>
            <sdk:DataGridTextColumn x:Name="ticketNameColumn" Binding="{Binding Path=ticketName}" Header="Ticket Name" Width="SizeToHeader" />
            <sdk:DataGridTextColumn x:Name="ticketDescColumn" Binding="{Binding Path=ticketDesc}" Header="Ticket Desc" Width="SizeToHeader" />
            <sdk:DataGridTextColumn x:Name="ticketNumberColumn" Binding="{Binding Path=ticketNumber}" Header="Ticket Number" Width="SizeToHeader" />
            <sdk:DataGridTextColumn x:Name="ticketTypeIdColumn" Binding="{Binding Path=ticketTypeId}" Header="Ticket Type Id" Width="SizeToHeader" />
            <sdk:DataGridTextColumn x:Name="seatIdColumn" Binding="{Binding Path=seatId}" Header="Seat Id" Width="SizeToHeader" />
            <sdk:DataGridTextColumn x:Name="showIdColumn" Binding="{Binding Path=showId}" Header="Show Id" Width="SizeToHeader" />
        </sdk:DataGrid.Columns>
    </sdk:DataGrid>


该代码具有特定的标头,例如seatId和showId,我希望它们显示座位和表演的实际名称,但是我将如何查询这一点,因为我在Silverlight应用程序中使用了域服务和上下文。

如果您需要更多信息,请告诉我。

谢谢。

编辑:
用于绑定的查询:

EntityQuery<Web.Ticket> query =
               from t in _ticketContext.GetTicketsQuery()
               where t.bookingId == data.bookingId
               select t;
        LoadOperation<Web.Ticket> loadOp = _ticketContext.Load(query);
        tk.ticketDataGrid.ItemsSource = loadOp.Entities;


编辑:
资料模型:



编辑:
来自域服务的查询代码:

    public IQueryable<Ticket> GetTickets()
    {
        return this.ObjectContext.Tickets.Include("Seat");
    }

最佳答案

为了给您一个完整的答案...

这是关于SO的link描述导航属性

如果您的票证实体具有SeatID(按DB术语,是外键),则可以创建一个Navigation属性,它将票证实体连接到Seats实体。用SQL术语来说,这类似于编写如下内容:

Select Ticket.Name, Seats.SeatName JOIN Seats ON Ticket.SeatID = Seats.SeatID

就您而言,您将使用类似以下的方法:

EntityQuery<Web.Ticket> query =
           from t in _ticketContext.GetTicketsQuery().Include("Seats")
           where t.bookingId == data.bookingId
           select t;
    LoadOperation<Web.Ticket> loadOp = _ticketContext.Load(query);
    tk.ticketDataGrid.ItemsSource = loadOp.Entities;


编辑:在您的票证对象的元数据中,您应该看到类似

public Seat Seats { get; set; }


添加:

[Include]
public Seat Seats { get; set; }

10-04 18:50