Using Linq to Sql is not updated, but does not throw an exception

Running .net 2008, asp.net, Linq to sql, sql server 2008 express

Foo f = db.Foo.First(x => x.ID == id);
f.IsValid = true;
db.SubmitChanges();

I have a very simple table that has several fields and no FK restrictions. None of the data is saved when .SubmitChanges () is called, but an error does not occur. Any ideas?

Without using any explicit transaction area, fields are not generated automatically and triggers are not started on the server.

+3
source share
4 answers

, , , - db.Log = Console.Out;, , - TSQL ( : SQL). , , IsValid - , ( ).

, , , (db.ObjectTrackingEnabled).

:

  • Complete() TransactionScope ( TransactionScope)
  • ( ), ( ), (/bin/debug /bin/release ).

, IsValid db- ( )

+3

IsValid f, x.

Foo f = db.Foo.First(x => x.ID == id); 
f.IsValid = true; 
db.SubmitChanges(); 

Complete TransactionScope, .

+2

IsValid AutoGenerated ? , , , . , , DB, , , "", 0 (false)?

+2

It turns out that the primary key has been deleted from the database since the last use of this application. When I recently updated .dbml, it was generated without a primary key. Adding this hotfix resolves the issue.

+1
source

Source: https://habr.com/ru/post/1738052/


All Articles