Yesterday I posted this question , which made me detect a huge problem!
I have a decimal column in my database called Units when I set the column value to NON ZERO and SubmitChanges updates the columns with the new value. If I try to set the column value to ZERO, SubmitChanges does not update the column.
data.Units = this.ReadProperty<decimal>(UnitsProperty); data.UnitPrice = this.ReadProperty<decimal>(UnitPriceProperty); data.Price = this.ReadProperty<decimal>(PriceProperty);
I looked at the DataContext log and I see that a field with a null value is not included in the request. Even if I try to discredit the change, Linq ignores it.
data.Units = 0; data.UnitPrice = 0; data.Price = 0;
Needless to say, this is killing me! Any ideas why this is happening?
Decision
I figured out my problem using the SO community. My problem was caused by the fact that when I created the object to join, the default value for the column was set to zero, so when he tried to set the value to zero ... LinqToSql says hey ... nothing changed, so I didn’t updating the value.
What I'm doing now ... just to make it work is the following:
ctx.DataContext.InvoiceItems.Attach(data, true);
It seems that all values are written to the database. It works for now.
mattruma
source share