I don’t know what’s wrong with this code , this code compile successfully but doesn’t update database . do i miss some thing ?
DataClassesDataContext db = new DataClassesDataContext();
var query = from p in db.AllPatiences
select p;
int newID = 1001;
foreach (AllPatience patient in query)
{
patient.Id = newID.ToString();
newID++;
}
db.SubmitChanges();
I found the problem , For Update like that , It’s necessary to have primary key . The reason my table didn’t have primary key was : I imported those data from an Excel file , So i didn’t have Primary key .