EF4: LINQ 2 Entities query works in C# but not in VB

后端 未结 4 452
滥情空心
滥情空心 2021-02-03 13:53

[EDITED: I left the original question below, with some more context and code to reproduce the problem. The short version below contains the essence of the question]

Shor

4条回答
  •  忘了有多久
    2021-02-03 14:39

    Does this work?

        Dim a = From p In products Join o In orders On p.Id Equals o.ProductId
                Order By p.DateCreated
                Select New With {.id = p.Id, .OrderDate = o.OrderDate, .CustomerId = o.CustomerId, .DateCreated = p.DateCreated}
    
        Dim b = From outerOrder In orders _
                Where outerOrder.OrderDate = currentDate _
                AndAlso outerOrder.ProductId = _
                (From x In a Where x.OrderDate = outerOrder.OrderDate _
                 AndAlso x.CustomerId = outerOrder.CustomerId _
                 Select x.id).FirstOrDefault
    

提交回复
热议问题