Here’s what I’m trying to do:
I have Orders, OrderItems, and Vendors. Each Order can have multiple OrderItems, and each OrderItem is tied to a Vendor. I have a screen that shows the order items for each order. On that screen is a a drop down list of vendors that allows you to filter the list of order items. The problem is that the drop down list shows all of the vendors in the database (hundreds) and I’ve been trying to get that list to only show the vendors that are tied to order items (generally fewer than a dozen).
If I was using SQL, I would do something like this:
SELECT VendorID, VendorName
FROM Vendors V
JOIN OrderItems O ON V.VendorID = O.VendorID
WHERE O.OrderID = @OrderID
or this:
SELECT VendorID, VendorName
FROM Vendors
WHERE VendorID IN (SELECT VendorID
FROM OrderItems
WHERE OrderID = @OrderID)
I can’t figure out how to do this in Lightswitch, as it doesn’t allow joins in the query designer, or in Linq queries. I also can’t figure out how to use something like the IN operator.
Any ideas?
Well, it turned out that Lightswitch doesn’t let you do queries across different datasets. In this case, I had some local tables for Order and Order Items, and a table from our data warehouse with the Vendors. I made a local table for the vendors, imported the data from the data warehouse, and now everything is working as expected.