var ud = new List<UserDivision>();
ud.AddRange(identityUser.UserDivisions);
_context.Entry(identityUser).State = EntityState.Modified;
try
{
_context.UserDivisions.RemoveRange(_context.UserDivisions.Where(w => w.IdentityUserId == identityUser.Id));
await _context.SaveChangesAsync();
_context.UserDivisions.AddRange(ud);
await _context.SaveChangesAsync();
}
public App()
{
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
}
static void MyHandler(object sender, UnhandledExceptionEventArgs args)
{
Exception e = (Exception) args.ExceptionObject;
Console.WriteLine("MyHandler caught : " + e.Message);
Console.WriteLine("Runtime terminating: {0}", args.IsTerminating);
}
из книг, Троелсен, Шилдт, Рихтер