Possible Duplicate:
Why are my LINQ INSERTS not persisting in SQL Server CE 3.5?
I have a local database "Database1.sdf" and i'm trying to insert data into the table "User" using LinqToSql.
public void DBTest()
{
string con = "Data Source=|DataDirectory|\\Database1.sdf";
Database1 db = new Database1(con);
User user=new User();
user.ID=3;
user.Name="testdata";
db.User.InsertOnSubmit(user);
db.SubmitChanges();
var q = from t in db.User
select t;
foreach (var t in q)
{
Console.Out.WriteLine(t.Name);
}
}
The select query after the insertion works fine and shows the result, but the database is not updated. If i go and 开发者_运维知识库check the table manually it is empty. If i run the program again it doesn't throw any exception of primary key violation.
Thanks
Why are my LINQ INSERTS not persisting in SQL Server CE 3.5?
精彩评论