Net core application. I have come up with below problem. I am trying updating values in db table.
public async Task<MyResponseModel> Update(RequestModel request)
{
IEnumerable<MyModel> mymodel = await _myRepository.GetAsync(x => Ids.Contains(x.Id));
List<MyModel> copy = new List<MyModel>();
copy.AddRange(mymodel)
for (int i = 0; i < mymodel.Count; i++)
{
//some property update
}
myRepository.UpdateRange(mymodel);
await _unitOfWork.CompleteAsync().ConfigureAwait(false);
here problem is in above code in copy variable i want to keep old values directly returned from first query. But problem is after executing update command even my copy variable values will be updated with new values those are updated. I want to keep old values in copy list which was there before updating. Can someone help me to find the root cause of it. Any help would be appreciated. Thanks