LINQ - updating a null integer data field

I have a field with the data type int?

price and allow null when I set

book.price = null;

      

and to update, it doesn't persist and throws no exceptions when I change the # null, that's ok. I want to set it to null.

0


source to share


2 answers


Make sure the field is null in the database and reflected as such in the dbml. Regenerate the dbml for the table to be sure. (Drop the tab from dbml and add again)



All I can say is that it works for us, so this is very strange.

0


source


I'm not a suyer. I understand the question, this part is unclear:

"when I change # null, that's okay"

Did you forget to call



db.SaveChanges();

      

(where [db] is the name of your Entites) This is a simple mistake I often make: P

0


source







All Articles