What is the difference between System.Linq.Enumerable.WhereListIterator and System.Linq.Enumerable.WhereSelectListIterator?
One difference I noticed is the WhereListIterator type, which reflects changes in the collection object, but WhereSelectListIterator is not
I will make it more clear, for example.
I have a script in which I retrieve my domain object from a repository
var buckets = testRepository.GetBuckets(testIds);
Then I select specific buckets from the above collection inside the loop
var bucketsForTest = buckets.Where(bucket => bucket.TestID == test.testId);
Then I change one property of all the Bucket objects inside the LooserTrafficDisributor object method.
ITrafficDistributor distributor = new LooserTrafficDisributor(bucketsForTest);
IEnumerable<Bucket> updatedBuckets = distributor.Distribute(test.AutoDecision);
Constructor LooserTrafficDisributor
public LooserTrafficDisributor(IEnumerable<Bucket> allBuckets)
{
this.allBuckets = allBuckets;
}
The distributed method inside LooserTrafficDistributor is as follows
private IEnumerable<Bucket> DistributeTraffic(bool autoDecision)
{
allBuckets.Where(bucket=> bucket.IsControl == false).ToList()
.ForEach(bucket => bucket.TrafficPercentage += 10 ));
return allBuckets
}
IEnumerable updatedBuckets.
, , Bucket , , Bucket
var bucketsForTest = testRows.Where(testrow => testrow.url == url.url).Select(currRow => new Bucket
{
TestID = currRow.TestId,
BucketID = currRow.BucketId,
BucketName = currRow.c_bucket_name,
TrafficPercentage = Convert.ToInt32(currRow.i_bucket_percentage),
IsControl = currRow.b_is_control,
IsEnabled = currRow.b_enabled,
UpdatedAdminId = currRow.i_updated_admin_id,
LogAsSection = currRow.i_log_as_section
}) ;
ITrafficDistributor distributor = new LooserTrafficDisributor(bucketsForTest);
IEnumerable<Bucket> updatedBuckets = distributor.Distribute(test.AutoDecision, strategy.GetStatisticallySignificantLoosingBucketIds());
, IEnumerable updatedBuckets.
Infact DistributeTraffic, .