I am trying to work out how compare two lists of things. In my DB I have thing called “Entity”. An Entity is a table of other things such as people, organizations, teams, etc. I would like the user to have ability to add these Entities to a unique messaging/chat group. Each group would be distinct based on its membership of Entities.
Functionally I would like the user to be able to create a messaging a group but prevent the creation of a duplicate messaging group with the same exact members.
For example if a user creates a messaging group with Entities A, B, and C they should be prevented from creating another group containing the exact Entities A, B and C. They should however be allowed to create groups (one instance only) with combinations A and B, B and C, A and C, or A, B, C D, etc.
In the example below I want check if a MessageGroupMembers_Entities exists as a unique group of entities in the db. The problem is the that the “contains” operator does not allow me to compare two lists of things and determine an exact match. I can only check if one item in the list is contained in the Members list.
I tried to implement a simple brute force method like the below, but was not able to get correct match if there were fewer than three things in the matched list.
I have been banging my head trying to figure a workaround. I feel like I am missing something obvious.
Any help would be greatly appreciated.