generics - Compare 2 lists using linq -


I'm a linq noob .... can someone please let me know how some of them can get it using Link. I 'am trying to compare 2 lists in both directions ...

  Internal Zero UpdateUserTeams (int iUserID) {UserTeamCollection Current Teams = GetUserTeams (iUserID); UserTeamCollection UpdatedTeams = this; Forex Currency (Usatam in Current Tutorial) {if updated (Consistent Team (UTIID)) {RemoveTeamFromDB (); }} Foreach (UsTatam in UpdatedTeams) {if (! Current Timms.companies (ut.ID)) {AddTeamToDB (); }}} Hammer (Int iTeamID) included in Public Hair {Return it. Any (t = & gt; tid == iTeamID); }  

Then change your starting question to English requirement:

  for each user  foreach (UserTime in CurrentTem) // If (UpdatedTeams.ContainsTeam (ut.ID)) // This update is not in the list of team {RemoveTeamFromDB (); // Remove the database from the list of updated databases for each team}} foreach (UserTeam has been updated) // If (! Current TIM.Content Team (UTIID)) // If the current team is not included update Team {AddTeamToDB (); // Add team to database}}  

Therefore, you want to do this:

  // Not all of the existing teams are being updated Select teams list current Team.Except (UpdatedTeams). All (Team = & gt; {RemoveTeamFromDB (Team); Return True;}); // Select all updated teams not updated in the list of current teams. Updated. Power (currentTam). All (Team = & gt; {AddTeamToDB (Team); Verification Back;});  

Ensure that your UserTeam object has an equal and override for GetHashCode methods, so that the comparison between two users is correct :)


Comments