public IEnumerable<ComputedData> Compute (IEnumerable<DataSet> data, IEnumerable<Variations> variationData)
{
// I need to create one ComputedData instance for each item inside the IEnumerable<DataSet> data
// DataSet has properties: int ID, int Valu1, int Value2
// ComputedData has properties: int ID, int Result, int Variation
// variationData has properties: int ID, int Variation
var computedDate = data.Select (i => new ComputedData ()
{
ID = i.ID,
Result = i.value1 + i.value2
});
// ISSUE is here
foreach (var item in computedDate )
{
var id = item.ID;
// I need to find the corresponding element
// (with same ID) on IEnumerable<Variations> variationData
// and assign item.Variation =
// But getting Possible Multiple Enumeration warning
// and item.Variation become zero always !
}
}
Issue is the use of foreach loop. Is there any other way to solve this issue. Even though the code is working, item.Variation is always zero. That shouldn't be the case. Any suggestions ?