I have 3 entities, users, tasks and permissions. Users can have many permissions. Tasks also have many permission associated with them. The idea that I am trying to capture in my query is this: My tasks need to be done by users with all the correct permissions required by the task.
I am struggling with the query. I think this is what I need:
var userList = context.Users
.Include("Permissions")
.Where(x => neededPermissionFromTask.Except(x.Permissions).Count() == 0).ToList();
But I get an exception:
Unable to create a constant value of type ‘Permission’. Only primitive
types (‘such as Int32, String, and Guid’) are supported in this
context.
Appreciate any help, suggestions or comments.
Instead of passing list of Permission objects, pass ids of those permissions: