C# Grabbing subset of table based off a Hashset if Ints

27 Views Asked by At

I have an Order and OrderMaster table. First I query the Master table, I then create a hashset of a column of Ints from that table. Lastly I want to get all orders that have those values.

When I do the contains, the ToList() fails and I get an error

Type bool does not contain member ToList

What am I doing wrong here?

mappings = await _context.OrderMapping
                         .Where((OrderMapping em) => em.MOID == UID)
                         .ToListAsync();

HashSet<int> ids2 = new HashSet<int>((mappings.Select(a => a.ORDERMAPID)));

orders = await _context.Order
                       .Where(x => ids2.Contains(x.ORDERMAPID)
                       .ToListAsync();
1

There are 1 best solutions below

0
kakebake On BEST ANSWER

Seems like you are missing a ")" after Contains(...). The following should work :)

orders = await _context.Order.Where(x => ids2.Contains(x.ORDERMAPID)).ToListAsync();