Inserting Default Data

Mar 27, 2008 at 10:24 PM
Some tables need default data, now in ruby you would use active record to do this. In Rik Migrations you have two options

  • Use SQL and execute a non reader
  • Hook up to your own code and use that.

How about this for an alternative, as it should tidy up the code being created.

db.InsertInto("Table_Name", new { Id=1, Name="Hello Wolrld});

Something along those lines.
Mar 28, 2008 at 2:10 AM
This sounds like a good idea. I like the syntax.

Perhaps also have it accessible from the table class so you can end up with something like:

var t = db.AddTable("Joe");
t.AddColumn<string>("Fred", 128);

t.Insert(new {Fred = "Test1"});
t.Insert(new {Fred = "Test2"});

The actual implementation would still be in the provider class though.
Mar 28, 2008 at 9:57 AM
Yeah I like that it reads nicely.

I'm also toying with the idea of a linq syntax to pull information out of the database, something simple and generic like

var data = from table in _db.Table("Joe") Where table.Column("Fred").Contains("red") select new [] { Name=table.Column("Fred")};


Needs more thought and probably it's own assembly so not to linq the whole of RikMigrations to .net 3.5
Mar 28, 2008 at 9:57 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.