Check if database table record with specified id contains a list c#?

Viewed 41

I have a table called PeopleActivityGroup in SQL.

Say that the table has this data: Table

From Front-End I receive an object containing a List of PeopleActivityGroup like this:

{
 "peopleId": "PeopleId1"
 "peopleActivityGroupList": [
     {
       "ActivityId ": "ActId4",
     },
     {
       "ActivityId ": "ActId2",
     },
     {
       "ActivityId ": "ActId3",
     },
 ]
}

How can I check if that table, given the PeopleId contains each ActivityId from the list?


In the end, it would be that if my query == null then I know there is no element corresponding to that list of ActivityId for that PeopleId.

Otherwise, my query will return all the ActivityIds for that PeopleId?

Does anyone know how to do that?

1 Answers
var query = PeopleActivityGroup.Where(t=>t.PeopleId==peopleId).Select(t=>t.ActivityId).Tolist();
Related