A191919
A191919

Reputation: 3442

Linq context behaviour

I am using linq

var remove = WE.Item.Where(key => !response.Any(p2 => p2.ItemID == key.ItemID)).ToList();

and occure error. This is because i am using ToList()? How to fix it?

Additional information: Unable to create a constant value of type 'IBD.Models.Stool'. Only primitive types or enumeration types are supported in this context.

Upvotes: 0

Views: 43

Answers (1)

juharr
juharr

Reputation: 32266

It looks like you need to pull the ids out of response first so you can pass the list into your Linq provider

var ids = response.Select(p => p.ItemID).ToList();
var remove = WE.Item.Where(key => !ids.Contains(key.ItemID)).ToList();

Upvotes: 1

Related Questions