I was wondering if there wasn't an optimal way for this code.
List<CollectionFormFieldRecord> dataFields = new List<CollectionFormFieldRecord>();
foreach (CollectionRelationModel relation in relations)
{
foreach (var field in visibleFields)
{
if (field.SourceCollectionsID == relation.ChildCollectionID)
dataFields.Add(field);
}
}
When a field (visibleFields) has a SourceCollectionsID
that exists in the relations list then the field must be added to a separated list.
I tried somethings with LINQ but didn't know how to compare a property with a property in a list.