Home > Software engineering >  Check if database table record with specified id contains a list c#?
Check if database table record with specified id contains a list c#?

Time:09-12

I have a table called PeopleActivityGroup in SQL.

Say that the table has this data: Table

From Front-End i recieve 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?


At 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?

Anyone knows how to do that?

CodePudding user response:

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