【问题标题】:Entity DataSource Include Feature实体数据源包含功能
【发布时间】:2013-10-27 10:20:51
【问题描述】:

我正在使用Linq to EntityEntity Datasource。我有一个包含我所有表格的edmx 文件。我正在尝试在 entity datasource 属性上使用包含功能。

    <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 B 中有一个外键,而table Btable C 中有一个外键。使用我的gridviewentity datasource 如何使用include 功能从表C 中获取值。表A 只能访问表B(因此我可以从表B 中获取值)但我需要表中的值C(我不能在我的entity datasourceinclude 表C,因为A 和C 没有链接)。

【问题讨论】:

    标签: c# linq include linq-to-entities entitydatasource


    【解决方案1】:

    您可以通过在Include 属性中将相关属性链接在一起来做到这一点,如下所示:Employee_Personal_Info.TableC

    【讨论】:

      猜你喜欢
      • 2011-08-09
      • 2010-11-17
      • 2018-01-28
      • 2017-07-19
      • 2021-10-16
      • 1970-01-01
      • 2013-09-23
      • 1970-01-01
      相关资源
      最近更新 更多