Efficient searching of collections

  • Thread starter Thread starter Ritmo2k
  • Start date Start date
R

Ritmo2k

Guest
I have two classes that each resemble a row of tabular data, one is an Entity Framework model and another is a model from a strongly typed csv parsing implementation. I don't have the luxury of performing my join in SQL which is unfortunate, so I need to match a single row from one collection to a row from the other collection. The criteria is detailed and involves the comparison of a field on one model to the string format product of two fields in the other model.

Given that I don't have the luxury of the luxury of SQL and the types differ wildly, what is a more efficient approach for iterating one collection and finding the match in another collection than the O(n2) approach of re-enumerating the entire second collection for each instance of the first collection?

My match criteria resembles:

ModelA.FieldA == ModelB.Field1;
ModelA.FieldB == ModelB.Field2;
ModelA.FieldC == $"[{ModelB.Field3}] [{ModelB.Field4}]";
Thanks!

Continue reading...
 
Back
Top