I have something like this:
var dbTransactions = context.Transactions.Where(t => t.Date >= yesterday).Select(t => t).ToList();
Now I would like to remove the objects from the dbTransactions list, but not from the real database. Later I call context.SaveChanges() , and if I did this, it would delete the lines from my db. How to disable change tracking for dbTransactions ?
dbTransactions
context.SaveChanges()
I think you can use AsNoTracking and use Detach for transactions
Youcontext.YourEntities.AsNoTracking().Where);
or use
Youcontext.Transactions.Detach(obj);
Remove these objects from the context using Detach() :
Detach()
context.Transactions.Detach(obj);
so you will need to restore this list, but then just go through it and disconnect them.