I am hitting an API and upserting my db with the results.
Initially, it inserts all of the entities (currencies).
Then each subsequent API call updates them. Sometimes, some of the 'currencies' are no longer available and I want to set 'IsActive' to false for that 'currency'. (to keep historical data)
How do I update one field in all entities where the entities do not exist in the list without doing a loop? (is it possible?)
Tried:
foreach (var cur in context.Currencies.Where(x => !x.Symbol.Contains(apiCurrencies.Values.Select(y => y.Name).ToString())).ToList())
{
cur.IsActive = false;
context.Currencies.Update(cur);
context.SaveChanges();
}