EmployeeEntitiesDataContext dc =null;
try
{
EmployeeEntitiesDataContext dc = new EmployeeEntitiesDataContext("http://ramsqlbi:40705/sites/gqs/");
EntityList<EmployeeItem> emp = dc.GetList<EmployeeItem>("Employee");
var updatedResult = (from empToUpd in emp
where empToUpd.FirstName == "Yagnesh"
select empToUpd).First();
updatedResult.FirstName = "Yagnesh2";
updatedResult.Title = "Kotecha";
dc.SubmitChanges();
}
catch (Microsoft.SharePoint.Linq.ChangeConflictException exc)
{
foreach (ObjectChangeConflict conflicts in dc.ChangeConflicts)
{
//conflicts.Resolve(RefreshMode.KeepCurrentValues);//Keep current value and override anything in DB with this value
//conflicts.Resolve(RefreshMode.OverwriteCurrentValues);//Keep Database version
conflicts.Resolve(RefreshMode.KeepChanges);
}
dc.SubmitChanges();
}
No comments:
Post a Comment