public int SaveTraceAndMeasurements(MeasuredTrace measuredTrace) { var changeCount = 0; if ( Traces.Any( t => string.Equals(t.PackageFileName, measuredTrace.PackageFileName, StringComparison.OrdinalIgnoreCase))) { Traces.Update(measuredTrace); } else { Traces.Add(measuredTrace); } changeCount += SaveChanges(); foreach (var m in measuredTrace.GetMeasurementsAll()) { AddMeasurementByTypeInfer(m); } changeCount += SaveChanges(); return(changeCount); }