Linq insert statement inserts nothing, does not fail either

Posted by pietjepoeier on Stack Overflow See other posts from Stack Overflow or by pietjepoeier
Published on 2010-03-26T17:47:16Z Indexed on 2010/03/26 17:53 UTC
Read the original article Hit count: 426

Filed under:
|
|
|

I am trying to insert a new account in my Acccounts table with linq. I tried using the EntityModel and Linq2Sql. I get no insert into my database nor an exception of any kind.

public static Linq2SQLDataContext dataContext {
        get { return new Linq2SQLDataContext(); }
    }

try {
      //EntityModel
      Accounts acc = Accounts.CreateAccounts(0, Voornaam, Straat, Huisnummer, Stad, Land, 15, EmailReg, Password1);
      Entities.AddToAccounts(acc);
      Entities.SaveChanges();

      //Linq 2 SQL
      Account account = new Account { City = Stad, Country = Land, EmailAddress = EmailReg, Name = Voornaam, Password = Password1, Street = Straat, StreetNr = Huisnummer, StreetNrAdd = Toevoeging, Points = 25 };
      dataContext.Accounts.InsertOnSubmit(account); 

      var conf = dataContext.ChangeConflicts;  // No changeConflicts
      ChangeSet set = dataContext.GetChangeSet(); // 0 inserts, 0 updates, 0 deletes

    try {
        dataContext.SubmitChanges();
    } catch (Exception ex) { }

        } catch (EntityException ex) {          

    }

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about linq-to-sql