Answer the question
In order to leave comments, you need to log in
Why is it not saved to the database?
There is such a code
var user = await db.Users.FindAsync(id);
user.Age = 20;
var someRes = user.Table1.Table2.SelectMany(
s =>//тут критерии выбора
).ToList();
for (int i = 0; i < someRes.Count; i++)
{
var r = someRes [i];
r.DateTime = DateTime.UtcNow;
}
await db.SaveChangesAsync();
Answer the question
In order to leave comments, you need to log in
You forgot to call Update on every element that has changed.
More or less like thisdb.Users.Update(user);
No need to do ToList(), this method makes a new list, while changes in entities are not tracked by EF.
var result = context.Users.Include(...).Where(...);
foreach(User u in result)
{
u.Name="Domain\\"+Name;
}
await context.SaveChangesAsync();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question