If performance is important, I suggest that you first give the Card class a property that returns the part after the '|' character. Depending on how often you want to make this request compared to how often you create a Map, you may even need to allow the constructor to split the Ref transaction into the part before the '|' character and the part after "|".
Whatever method you choose is not important for the request. Suppose the Card class has the property:
string Guid {get {return ...;}
I understand that you need a sequence of all Cards from the cardDetails sequence that do not have a Guid, which is equal to any of the TxnDetails transactions in the transDetails sequence.
Or, in other words: if you make a sequence of all used commands in TxnDetails, you want all the cards in CardDetails to have a pointer that is not in the sequence of all used commands.
You can use Any () for this, but that will mean that you need to look for the transDetails sequence for each map you want to check.
Whenever you need to check if a particular element is in a sequence or not, it is better to convert the sequence once to a dictionary or HashSet. Whatever you create depends on whether you only need a key or an element with a key. Create a dictionary / hashset only once and very quickly search for an item using the key.
In our case, we only need a sequence with the guides used, it does not matter in which transaction it is used.
var usedGuids = transDetails.Select(transDetail => transDetail.TxnDetails).Distinct(); var hashedGuids = new HashSet(usedGuids);
(I made two statements to make it easier to understand what has been done)
Now that I have a GUID, I can check very quickly if it is used or not:
bool guidIsUsed = usedGuids.Contains(myGuid);
So, your sequence of cards in cardDetails with a GUID that is not in transDetails is:
var hashedGuids = new HashSet(transDetails.Select(transDetail => transDetail.TxnDetails).Distinct()); var requestedCards = cardDetails.Where(card => !hashedGuids.Contains(card.Guid));