【问题标题】:Expand() with more than one Where condition具有多个 Where 条件的 Expand()
【发布时间】:2014-02-13 21:53:01
【问题描述】:

在我的应用程序中,我有下表:

return (
  (
    from o in ctxImport.TableA.Expand("TableD/TableC,TableD/TableB") 
    where o.TableAID == ID select o
  ) as DataServiceQuery<DataService.TableA>
);

这里的TableA、TableB、TableC是父表。 TableD就是这3个表之间的映射表。

以上代码仅在 TableA 主键上有 where 条件。我需要在上面为 TableB 主键添加一个 where 条件。

输出列表应该相同。

ctxImport 是数据库实体的对象。

你能帮我解决这些问题吗?

【问题讨论】:

    标签: c# asp.net entity-framework lambda


    【解决方案1】:

    你可以的

    from o in ctxImport.TableA.Expand("TableD/TableC,TableD/TableB") 
    where o.TableAID == ID select o
       && o.TableD.Any(d => d.TableB.Any(b => b.Id == condition))
    

    假设TableDTableB 是集合导航属性。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-28
    • 2019-08-25
    • 2020-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-16
    相关资源
    最近更新 更多