I have encountered a problem with the SubmitChanges method -- I have reduced the code and the schema to a bare minimum without discovering the nature of the problem.
With a db having a single (self-referential table), the InsertOnSubmit method does not actually ever issue an SQL INSERT command, and the table remains empty.
I am using VS2010, .NET 4.0 and Devart.Data.SQLite runtime version 2.0.50727.
Code: Select all
using (PeopleDataContext db = PeopleDataContext.CreatePeopleContext(path, deleteExisting))
{
SQLiteMonitor DbMonitor = new SQLiteMonitor();
DbMonitor.IsActive = true;
/*** This code generates no error of any kind, but DbMonitor shows that the INSERT command
* is never executed, and the Person collection remains empty.
*
Assert.AreEqual(0, db.People.Count());
Person p = new Person();
p.Name = "Nolo Contendre";
db.People.InsertOnSubmit(p);
db.SubmitChanges();
* **/
/** This code performs the INSERT correctly, but loses the entire advantage of using
* the higher level code. **/
SQLiteConnection conn = db.Connection as SQLiteConnection;
if (conn != null)
{
conn.Open();
SQLiteTransaction tx = conn.BeginTransaction();
SQLiteCommand cmd = new SQLiteCommand(@"INSERT INTO Person VALUES(NULL,NULL,'Nolo Contendre')", conn);
cmd.ExecuteNonQuery();
tx.Commit();
conn.Close();
}
Assert.IsTrue(db.People.Count() == 1, "People count != 1");
}
TIA.
--------------------------------------------------------------------------------