实体框架:在EF5中有效但在EF6中无效的查询

时间:2015-02-22 16:26:20

标签: vb.net entity-framework

我有这段代码:

Partial Public Class Myobj
  Public Property id As Integer
  Public property name as string
  Public Overridable Property chld As ICollection(Of chld) = New HashSet(Of chld) 
   End Class


 Partial Public Class Myobj
      <NotMapped> Public Property vls As integer
End Class

Partial Public Class chld
    Public Property id As Integer
    Public Property date1 as DateTime
    Public Property quantity as Integer
    Public Property ParentID as integer
    Public Overridable Property MyObj1 As MyObj
End Class 

Public Class PseudoMyObj
    Inherits MyObj
End Class

现在我的表格上有这段代码:

Dim dt1 as DateTime=CDate("08/08/2014")
 Dim list1 = (From t In context.MyObj Select New With { _
      .Parent = New PseudoMyObj With {  _
      .chld =  (From t2 in t.chld.AsQueryable.Where(Function(t3) t3.Date1>=dt1) Select t2), _
      .vls=(t.chld.AsQueryable.Where(Function(t2) t2.date1<dt1).Select(Function(t3) t3.quantity).DefaultIfEmpty.Sum()) _
}).ToList

Dim mylist as IEnumerable(of MyObj)=list1.Select(Function(t2) t2.Parent)

这适用于Entity Framework 5,但不适用于Entity Framework 6。 为什么? 谢谢!

0 个答案:

没有答案