Inserting Default Data

In the next version there will be a new way of inserting default data into a table below are some descriptions of how this can be done.

It can be used using the table command.

            Table table = db.AddTable("Table1");
            table.AddColumn<int>("ID").PrimaryKey().AutoGenerate();
            table.AddColumn<string>("Name", 20);
            table.Insert(new {ID = 1, Name = "Hello World"});            
            table.Save();


Or alternative through the Dataprovider, for example if the table already exists.

            // db.InsertDataInto("TableName", objectToUse, IsIdentityField);
            db.InsertDataInto("Table1", new { ID = 1, Name = "Hello World" }, true);

Last edited Mar 29, 2008 at 3:12 PM by AndyStewart, version 2

Comments

No comments yet.