How best to implement this for loop in C#?

The situation is very simple.

I have a UserData structure. There is field id, guid, name, and so on. I need to find a unique guid, which is in first database but not in the second.

Actually in the line:
if (GUIDListInTransitDB.Contains(el))
I need to check whether a certain guide in the bulkhead. Just how to do it?
I can not write:
if (GUIDListInTransitDB.Contains(el.guid))
in any case, the Studio swears that, in General, and logical.
How can that be? Is there a better solution and how it to use?

List<string> GUIDListExistsInTransitButNotInTargetdb; // Guide which are in transit, but not in the Target with them, we then will work
 List<userdata> GUIDListInTransitDB = TransitDbContext.GetGUIDList(11);
 List<userdata> GUIDListInTargetDB = TargetDbContext.GetGUIDList(11);

 foreach (var el in GUIDListInTargetDB)
{
 if (GUIDListInTransitDB.Contains(el)) 
continue;
else
{
 // GUIDListExistsInTransitButNotInTargetdb.Add(el.Guid);
}
 }</userdata></userdata></string>
July 9th 19 at 13:18
3 answers
July 9th 19 at 13:20
Solution
if (GUIDListInTransitDB.Select(g=>g.VISIT).Contains(el))
thank you, and after foreach loop it is as the right thing to do? - paula.Ste commented on July 9th 19 at 13:23
: it will be the same, just using linq better readability - nils_Will commented on July 9th 19 at 13:26
: And do not tell me where I have to cycle it can be a mistake. Why are all displayed 3 times? img.ctrlv.in/img/16/05/18/573c51b18f97a.png - paula.Ste commented on July 9th 19 at 13:29
show that comes to GUIDListTransitInDB - nils_Will commented on July 9th 19 at 13:32
July 9th 19 at 13:22
Solution
And do not tell me where I have to cycle it can be a mistake. Why are all displayed 3 times?

we need to check what information is included in GUIDListTransitInDB

and if you can optimize
if (!GUIDListTransitInDB.Select(g => g.guid).Contains(el.Guid))
{
GUIDListTransitButNoInTargetDB.Add(el.GUID);
}
You can also GUIDListTransitInDB.Where(g => g.guid == el.Guid).Count == 0 ? - paula.Ste commented on July 9th 19 at 13:25
July 9th 19 at 13:24
I need to find a unique guid, which is in first database but not in the second.

Why not do it on the side of the database? Elementary joinem same problem can be solved.

Eniwa, if you need operations with sets, why use dynamic arrays (List) ?
https://msdn.microsoft.com/en-us/library/bb460136(... - paula.Ste commented on July 9th 19 at 13:27

Find more questions by tags C#