I perform a query on a table Installation to get a list of Ids that are needed to query a table Product on a different database (before you ask, it has to be this way, can’t query across dbs). Here’s what the list looks like:
class Installation
{
Guid InstallationId
Guid ProductId
}
List<Installation> installs;
I don’t have any problems using this list for the query in to the Product table which looks like this:
var prods = (from p in context.Product
where installs.Select(i => i.ProductId).Contains(p.ProductId)
select new
{
ProductNumber = p.ProductNumber
// How do I get InstallationId from installs??
}).ToList();
What I need to know is how I can retrieve InstallationId from the list and store it in the new list?
Thanks in advance.
A slight refactoring of Jason’s answer to allow for the LinqToSql exception.