This project is read-only.
1
Vote

Problem with IDataRow reference equality and immediately executed operators

description

Simple repro:
 
// 100 records in csv file
List<DataRow> records = context.Read<DataRow>(A_CAR_RECORDS_FILE).ToList();
 
 
  HashSet<DataRow> mySet = new HashSet<DataRow>();
  records.ForEach(record => mySet.Add(record)); //Only ! record

  var result  = records.All(record => Object.ReferenceEquals(record, records[0])); //!!!!!true!!!!
 
You are reusing IDataRecord instance for every record in csvi? So its impossible to call e.g. OrderBy operator and expect correct results.

comments

renestein wrote Sep 27, 2012 at 5:08 PM

Has to be:
HashSet<DataRow> mySet = new HashSet<DataRow>();
records.ForEach(record => mySet.Add(record)); //Only 1 record

wrote Feb 14, 2013 at 3:16 AM