change it to
yield return ModifyRow(row);
On Tue, Sep 22, 2009 at 12:30 AM, MikeInVB <[email protected]>wrote:
>
> I started playing with Rhino-ETL over the weekend and came across
> something odd. When iterating through the rows in the override Execute
> method of an implementation of the AbstractOperation, the enumerable
> list of rows was cleared. Is this normal behavior or did I do
> something completely wrong?
>
> My example is as follows:
> namespace MySampleApp {
> class PrintNumberProcess : EtlProcess {
> protected override void Initialize() {
> Register(new EvenNumbers(7));
> Register(new PrintNumbers());
> RegisterLast(new BulkInsert());
> }
> }
> }
>
> PrintNumbers is where I was seeing the odd behavior:
>
> namespace MySampleApp {
> class PrintNumbers : AbstractOperation {
> public override IEnumerable<Row> Execute(IEnumerable<Row>
> rows) {
> //enumerating the Row appears to also clear the
> Enumeration.
> //So I'll push the contents of the Row into a list to pass
> along the pipeline of operations.
> List<Row> listOfRows = new List<Row>();
>
> foreach (Row row in rows) {
> Console.WriteLine(row["id"]);
> listOfRows.Add(ModifyRow(row));
> }
> Console.WriteLine("==========");
>
> return listOfRows.AsEnumerable();
> }
>
> private Row ModifyRow(Row r) {
> r["id"] = (int)r["id"] + 1;
> return r;
> }
> }
> }
>
> Thanks,
> Mike
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino Tools Dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rhino-tools-dev?hl=en
-~----------~----~----~----~------~----~------~--~---