Answer the question
In order to leave comments, you need to log in
What is the best way to implement this loop in C#?
The situation is very simple.
I have a UserData structure. There fields id, guid, name and so on. I need to find a unique guid that is in the first database but not in the second.
Actually in the line:
if (GUIDListInTransitDB.Contains(el))
I need to check if there is a certain guide in the bulkhead. But how to do it?
I can't write:
if (GUIDListInTransitDB.Contains(el.guid))
in any case, the studio swears, which in general is logical.
How to be then? Is there a better solution and how to use this solution?
List<string> GUIDListExistsInTransitButNotInTargetDB; // ГУИДы которые есть в транзите, но нет в Target, с ними мы потом и будем работать
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);
}
}
Answer the question
In order to leave comments, you need to log in
if (GUIDListInTransitDB.Select(g=>g.ВАШЕ_ГУИД_СВОЙСТВО).Contains(el))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question