关于尝试从实体框架加入2个表的LINQ连接问题

时间:2014-07-20 06:43:25

标签: linq

[DimAccount]         [FactFinance]

上面的2个表来自AdventureWorksDW2008数据库。

我正在尝试进行左连接,出于某种原因它会给我错误。我已经在没有外键的桌子上成功完成了这项工作。这是代码和错误。知道如何解决这个问题吗?

 Dim result = From q In da.DimAccount _
              Group Join p In da.FactFinance On p.AccountKey Equals q.AccountKey Into x = Group _
              From p In x.DefaultIfEmpty _
              Select New AccountInfo With { _
                            .AccountKey = q.AccountKey, _
                            .AccountDesc = q.AccountDescription, _
                            .Amount = p.Amount _
                         }

这是错误:

  

LINQ to Entities无法识别方法' System.Collections.Generic.IEnumerable 1[WindowsApplication1.FactFinance] DefaultIfEmpty[FactFinance](System.Collections.Generic.IEnumerable 1 [WindowsApplication1.FactFinance])'方法,并且此方法无法转换为商店表达式。

0 个答案:

没有答案