I'm migrating our DAL class library to .NET 4 (from .NET 3.5). We're using typed datasets quite often, and we often iterate over tables:
foreach(var row in ds.MyTable) var tmp = row.ID;
This does not work anymore, as the designer changes the dataset's code so that tables do not derive from TypedTableBase<T>
anymore, but from DataTable
(and implement the non-generic IEnumerable
). That's what the diff shows. Therefore, the row is of type object
at compile-time.
Does anybody know if this is the usual behavior? At the moment, I'm doing it the way shown below, but I hope there's a more elegant solution:
foreach(var row in ds.MyTable.Cast<MyDs.MyRow>()) var tmp = row.ID;