[Ironruby-core] Interop with Sql Mgmt Objects (SMO) - the "IronRuby Way"

Mark Wilkins wilkins.mark at gmail.com
Fri Nov 13 17:04:46 EST 2009

Thanks to casualjim in #ironruby, I figured out a way to do what I
needed, but would be interested to see if there is a more appropriate

I'm trying to use SMO to script objects from a SqlServer DB, using IR.
 In particular, I am calling
Microsoft::SqlServer::Management::Smo::Scripter.Script, which expects
an array of SmoObject's (SmoObject[]).

So...what is the best way to create this array?

I ended up doing the following:
@arsmo = System::Collections::Generic::List[SqlSmoObject].new
@arsmo << dev.tables["tablename"] # where dev.tables is a Smo::TableCollection
scripter.Script @arsmo.to_array

As I said...this works fine.  And...it also reminded me that
@arsmo.to_array is much different than @arsmo.to_a.  Just curious if
there is a better way?

I've tried something as simple as::
@arsmo = []
@arsmo << dev.tables["tablename"]
scripter.Script @arsmo

but I always get: "TypeError: can't convert Array into

p.s. I know I can also do dev.tables["tablename"].script, but I was
trying to assemble a list of everything I wanted scripted, then make
one call



More information about the Ironruby-core mailing list