I am using Linq to Entity
and Entity Datasource
. I have an edmx
file that contains all of my tables. I am trying to use the include feature on the entity datasource
properties.
<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>
This is an example of one of my datasource.
Text='<%# Eval("Employee_Personal_Info.Firstname") + " " + Eval("Employee_Personal_Info.Surname") %>'></asp:Label>
This is how i implement it in my gridview
(a label).
Now i am able to do this because table A
(Employee_Financial) has a foreign key in table B
(Employee_Personal_Info). Hence my include
statement works.
HERE IS MY ISSUE><
Using my example above. Lets say table A
has a foreign key in table B
and table B
has a foreign key in a table C
. Using my gridview
and entity datasource
how can i use the include
feature to get a value from table C. Table A only has access to table B (hence i can get value from table B) but I need values from Table C (and i cannot include
Table C in my entity datasource
because A and C are not linked).
You can do this by chaining the relevant properties together in the Include
attribute like so: Employee_Personal_Info.TableC
.