NotImplementedException while using SubmitChanges ( LINQ )

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
drichter
Posts: 20
Joined: Fri 21 Aug 2009 14:44

NotImplementedException while using SubmitChanges ( LINQ )

Post by drichter » Fri 21 Aug 2009 17:29

imagine i got a table ( testtable) with 2 columns:

- id ( PK )
- value

and a function call like this:

public void main()
{
testtable t = new testtable();
t.id = 10;
t.value = "test";
Updatetesttable(t);
}

public void Updatetesttable(testtable t)
{
DataContext db = new DataContext();
db.testtables.SubmitChanges(t);
}

An entry with id=10 actually exists in the db, but:

The "bold" part of the source throws a "NotImplementedException"... How am i supposed to update a table when i DON'T have access to the DataContext where i made the select with?!?!

Thanks ( this is very urgent )!

drichter
Posts: 20
Joined: Fri 21 Aug 2009 14:44

Post by drichter » Mon 24 Aug 2009 12:08

hello? administration? :)

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 25 Aug 2009 09:25

The update can be done as the following:

Code: Select all

    static void Main(string[] args) {

      Testtable oldT = new Testtable();
      oldT.Id = 10;
      oldT.Value = "test";
      
      Testtable newT = new Testtable();
      newT.Id = 10;
      newT.Value = "new test";

      Updatetesttable(newT, oldT);
    }

    public static void Updatetesttable(Testtable newT, Testtable oldT) {
      Postgresdatacontext db = new Postgresdatacontext();
      db.Testtables.Attach(newT, oldT);
      db.SubmitChanges();
    }
An alternative way:

Code: Select all

        DataContext db = new DataContext();
        var row = db.Testtables.Single(c => c.Id == 10);
        row.Value = "new test";
        db.SubmitChanges();

Post Reply