I have the following:
var db = new datesDataContext();
var query =
from ord in db.Dates
where ord.id == id
select ord;
foreach (Date ord in query)
{
ord.date1 = product.date1;
ord.name = product.name;
}
db.SubmitChanges();
It all runs fine (no errors, etc) except that SubmitChanges is not making the changes in the database.
ord.dat1 and ord.name are definitely being set…
edit: here’s my date class (it says partial but it’s the entire class, no other definition elsewhere):
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Dates")]
public partial class Date
{
private System.Nullable<int> _id;
private System.Nullable<System.DateTime> _date1 = DateTime.Now;
private string _name;
public Date()
{
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_id", DbType="Int")]
public System.Nullable<int> id
{
get
{
return this._id;
}
set
{
if ((this._id != value))
{
this._id = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Name="date", Storage="_date1", DbType="DateTime")]
public System.Nullable<System.DateTime> date1
{
get
{
return this._date1;
}
set
{
if ((this._date1 != value))
{
this._date1 = value;
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_name", DbType="Text", UpdateCheck=UpdateCheck.Never)]
public string name
{
get
{
return this._name;
}
set
{
if ((this._name != value))
{
this._name = value;
}
}
}
}
Is your Date class implementing INotifyPropertyChanged?
EDIT: implement INotifyPropertyChanged in your Date class
…..rest of class definition
and in each setter method use this code after changing values
PropertyName in your case is id, date1 and name.
You also need to specify Primary Key otherwise tracking changes will not work.