I am using Linq2Sql to update a row data but once I change the values I've researched this issue before and found the following possible reasons:
- Entity was not changed so no update occurs
- Entity is missing a primary key but no update occurs
None of these are the case in my situation.
I have my PK in my class and table. The GetChangeSet() of the data context indicates that there is atleast 1 update.
The only issues I see is that from the data context log is that no update statement is generated.
Does anyone have an idea what the issue could be.
Here is a sample of the code:
using(context db=new context())
{
db.Log=new System.IO.StreamWriter(sample){AutFlush=true};
MyObject obj=db.MyTable.SingleOrDefault(row=>Email==email);
if(obj!=null)
{
obj.FirstName=firstName;
obj.LastName=lastName;
System.Data.Linq.ChangeSet set=db.GetChangeSet();
db.SubmitChanges();
}
}