Note that there are some explanatory texts on larger screens.

plurals
  1. POFilter large collection
    text
    copied!<p>I have a collection of MyClass objects and i need to filter it by a combination of 17 fileds. </p> <p>I implemented an object MyClassFilter with the 17 possible fields and the condition for each one and a method:</p> <pre><code>bool PassFilter(MyClass ObjectToEvaluate) { return PassFilterVal(this.Workstream, ObjectToEvaluate.WorkStream) &amp;&amp; PassFilterVal(this.AssignedTo, ObjectToEvaluate.AssignedTo) &amp;&amp; PassFilterVal(this.ProcessingGroup, ObjectToEvaluate.ProcessingGroup) &amp;&amp; PassFilterVal(this.ScheduledStart, ObjectToEvaluate.ScheduledStart) &amp;&amp; PassFilterVal(this.EntityName, ObjectToEvaluate.EntityName) &amp;&amp; PassFilterVal(this.TaskIDs, ObjectToEvaluate.TaskID) &amp;&amp; PassFilterVal(this.ElementIDs, ObjectToEvaluate.EntityID) &amp;&amp; PassFilterVal(this.MappingIDs, ObjectToEvaluate.MappingID) &amp;&amp; PassFilterVal(this.EntityStatus, ObjectToEvaluate.EntityStatus) &amp;&amp; PassFilterVal(this.EntityType, ObjectToEvaluate.EntityType) &amp;&amp; PassFilterVal(this.NumberOfSteps, ObjectToEvaluate.ListOfSteps.Count) &amp;&amp; PassFilterVal(this.NumberOfDependancies, ObjectToEvaluate.ListOfParentDependancies.Count) &amp;&amp; PassFilterVal(this.NumberOfOpenIssues, ObjectToEvaluate.ListOfAllIssues.CountOpen) &amp;&amp; PassFilterVal(this.NumberOfRequirementsLinked, ObjectToEvaluate.RequierementsLinked) ; } </code></pre> <p>and my collection has a method </p> <pre><code>ListOfMyClass FilterList(MyClassFilter Filter){ ListOfMyClass FilteredList = new ListOfMyClass(); foreach (MyClass Task in this) { if (Filter.TaskPassFilter(Task)) FilteredList.Add(Task); } return FilteredList; } </code></pre> <p>It works fine as long as the collection is small but when I have 500 objects it start to be really slow. I have searched the net but all the examples are going object by object in the collection and asking filed by field if it pass or not.</p> <p>Any suggestions as how to improve performance?</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload