Click here to Skip to main content
15,885,061 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My Code :
C#
var chk = (from c in FMS.Depositers where c.RecepitNo == DepositNo select c).FirstOrDefault();
if(chk!=null)
{
                       chk.DepositStatus = "PreClosed"
                       gt.ApplyCurrentValues(chk.EntityKey.EntitySetName, chk);

                       gt.SaveChanges();
}



showing error like this:
An object with a key that matches the key of the supplied object could not be found in the ObjectStateManager. Verify that the key values of the supplied object match the key values of the object to which changes must be applied.
Posted

1 solution

You should change your code like this:
C#
var chk = (from c in FMS.Depositers where c.RecepitNo == DepositNo select c).FirstOrDefault();
if(chk!=null)
{
 chk.DepositStatus = "PreClosed";
 FMS.SaveChanges();
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900