2013-10-18 48 views
1

我正在使用Linq to EntityEntity Datasource。我有一個包含我所有表的edmx文件。我正在嘗試使用entity datasource屬性中的include功能。實體數據源包含功能

<asp:EntityDataSource ID="EntityDataSource2" runat="server" 
     ConnectionString="name=sspEntities" DefaultContainerName="xxx" 
     EnableFlattening="False" EntitySetName="Employee_Financial" 
     Include="Bank_Branch,Employee_Personal_Info,COA" EnableDelete="True" > 
    </asp:EntityDataSource> 

這是我的一個數據源的例子。

Text='<%# Eval("Employee_Personal_Info.Firstname") + " " + Eval("Employee_Personal_Info.Surname") %>'></asp:Label> 

這就是我在我的gridview(標籤)中實現它的方式。

現在我可以這樣做了,因爲table A(Employee_Financial)在table B(Employee_Personal_Info)中有一個外鍵。因此我的include聲明起作用。

這是我的問題> < 使用我上面的示例。可以說table A有一個外鍵在table Btable B有一個外鍵在table C。使用我的gridviewentity datasource如何使用include功能從表C中獲取值。表A只能訪問表B(因此我可以從表B中獲取值),但我需要表C中的值(並且我不能使用include表C在我的entity datasource中因爲A和C沒有鏈接)。

回答

2

您可以通過鏈接Include屬性中的相關屬性來完成此操作,例如:Employee_Personal_Info.TableC