tags:

views:

236

answers:

1

Given two tables, customer and orders, how would one do a linq query to entities to find any customers with open invoices started before a certain date?

+1  A: 

VB.net

Dim query = _
    From customer In customers _
    From order In orders _
    Where customer.CustomerID = order.Customer.CustomerID _
    And order.OrderDate <=  dtOrderDate _
    And order.IsOpen = True _
    Select New With _
    { _
        CustomerID = customer.CustomerID, _
        OrderID = order.SalesOrderID, _
        Total = order.TotalDue _
    }

I modified the code from the Query Expression Syntax Examples

I got there from the Linq to entites site

Nathan Koop