Null enumerator detected (Rhino DSL)

21 views
Skip to first unread message

Michael Gates

unread,
Jul 20, 2012, 7:31:09 PM7/20/12
to rhino-t...@googlegroups.com
I'm very new to this library and am trying to understand the Boo DSL. When I run the following code, I get "Null enumerator detected, are you trying to read from the first operation in the process?"
code:

import FileHelpers

[DelimitedRecord("|")]
public class LoyaltyRow:
    public Name as string
    public Loyalty as string

operation import_from_db:
    input "SourceDatabase", Command = """
      SELECT
        FirstName, LastName, LoyaltyNumber
      FROM LoyaltyTable
    """
    
operation transform_names:
    for row in rows:
      row.Name = row.FirstName + " " + row.LastName
      row.Loyalty = row.LoyaltyNumber.ToString()
      yield row

operation export_file:
    engine = Rhino.Etl.Core.Files.FluentFile.For[of LoyaltyRow]()
    file = engine.To("DatabaseExport.txt")
    for row in rows:
      record = row.ToObject[of LoyaltyRow]()
      file.Write(record)
      yield row
    file.Dispose()

process Test:
    import_from_db()
    transform_names()
    export_file()

Simone Busoli

unread,
Jul 20, 2012, 8:54:01 PM7/20/12
to rhino-t...@googlegroups.com
I'm not overly familiar with the DSL but I think that inlining the first operation inside the process itself instead of declaring it as a standalone operation should work.

Simone


--
You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rhino-tools-dev/-/D_cZ6Jq53b0J.
To post to this group, send email to rhino-t...@googlegroups.com.
To unsubscribe from this group, send email to rhino-tools-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rhino-tools-dev?hl=en.

Nathan Palmer

unread,
Jul 22, 2012, 10:28:28 AM7/22/12
to rhino-t...@googlegroups.com
Michael,

Did you get your problem resolved? Your code is almost 100% the same as the example here except for Simone's suggestion of inlining the first process.


Take a look and let us know if you have questions.

Nathan

Simone Busoli

unread,
Jul 22, 2012, 12:06:24 PM7/22/12
to rhino-t...@googlegroups.com
The point is basically that what the DSL is doing in that case is replacing the body of the Execute method of an AbstractOperation with the instantiation of the input operation, which therefore will not be executed when the process is run.
It's a limitation of the DSL I would say, and the workaround it either to write the input operation inline or do something like this:

operation import_from_db:
    op = ConventionInputCommandOperation("test")
    op.Command = "SELECT FirstName, LastName, LoyaltyNumber FROM LoyaltyTable"
    for row in op.Execute(null):
      yield row

Nathan Palmer

unread,
Jul 22, 2012, 4:37:56 PM7/22/12
to rhino-t...@googlegroups.com
I agree that it would be optimal to support both. I'm happy to accept a pull request if you have an update that would modify how this works.

Nathan Palmer
Reply all
Reply to author
Forward
0 new messages