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 )!
NotImplementedException while using SubmitChanges ( LINQ )
The update can be done as the following:
An alternative way:
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();
}
Code: Select all
DataContext db = new DataContext();
var row = db.Testtables.Single(c => c.Id == 10);
row.Value = "new test";
db.SubmitChanges();